mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
* Feature: Augment VFS file information with creation times & update some console functions to use VFS.
This commit is contained in:
parent
277cdf67b0
commit
948bc43d85
7 changed files with 36 additions and 23 deletions
|
|
@ -530,8 +530,12 @@ DefineEngineFunction(fileSize, S32, ( const char* fileName ),,
|
||||||
|
|
||||||
"@ingroup FileSystem")
|
"@ingroup FileSystem")
|
||||||
{
|
{
|
||||||
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName);
|
StrongRefPtr<Torque::FS::FileNode> node = Torque::FS::GetFileNode(fileName);
|
||||||
return Platform::getFileSize( sgScriptFilenameBuffer );
|
if (node.isValid())
|
||||||
|
{
|
||||||
|
return node->getSize();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineFunction( fileModifiedTime, String, ( const char* fileName ),,
|
DefineEngineFunction( fileModifiedTime, String, ( const char* fileName ),,
|
||||||
|
|
@ -609,13 +613,7 @@ DefineEngineFunction(fileDelete, bool, ( const char* path ),,
|
||||||
"@return True if file was successfully deleted\n"
|
"@return True if file was successfully deleted\n"
|
||||||
"@ingroup FileSystem")
|
"@ingroup FileSystem")
|
||||||
{
|
{
|
||||||
static char fileName[1024];
|
return Torque::FS::Remove(path);
|
||||||
static char sandboxFileName[1024];
|
|
||||||
|
|
||||||
Con::expandScriptFilename( fileName, sizeof( fileName ), path );
|
|
||||||
Platform::makeFullPathName(fileName, sandboxFileName, sizeof(sandboxFileName));
|
|
||||||
|
|
||||||
return dFileDelete(sandboxFileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -830,13 +828,7 @@ DefineEngineFunction( pathCopy, bool, ( const char* fromFile, const char* toFile
|
||||||
"@note Only present in a Tools build of Torque.\n"
|
"@note Only present in a Tools build of Torque.\n"
|
||||||
"@ingroup FileSystem")
|
"@ingroup FileSystem")
|
||||||
{
|
{
|
||||||
char qualifiedFromFile[ 2048 ];
|
return Torque::FS::CopyFile(fromFile, toFile, noOverwrite);
|
||||||
char qualifiedToFile[ 2048 ];
|
|
||||||
|
|
||||||
Platform::makeFullPathName( fromFile, qualifiedFromFile, sizeof( qualifiedFromFile ) );
|
|
||||||
Platform::makeFullPathName( toFile, qualifiedToFile, sizeof( qualifiedToFile ) );
|
|
||||||
|
|
||||||
return dPathCopy( qualifiedFromFile, qualifiedToFile, noOverwrite );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -876,11 +868,7 @@ DefineEngineFunction( createPath, bool, ( const char* path ),,
|
||||||
"@note Only present in a Tools build of Torque.\n"
|
"@note Only present in a Tools build of Torque.\n"
|
||||||
"@ingroup FileSystem" )
|
"@ingroup FileSystem" )
|
||||||
{
|
{
|
||||||
static char pathName[1024];
|
return Torque::FS::CreatePath(path);
|
||||||
|
|
||||||
Con::expandScriptFilename( pathName, sizeof( pathName ), path );
|
|
||||||
|
|
||||||
return Platform::createPath( pathName );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORQUE_TOOLS
|
#endif // TORQUE_TOOLS
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ namespace Torque
|
||||||
dMemset(mBuffer, 0, mBufferSize);
|
dMemset(mBuffer, 0, mBufferSize);
|
||||||
mModified = Time::getCurrentTime();
|
mModified = Time::getCurrentTime();
|
||||||
mLastAccess = mModified;
|
mLastAccess = mModified;
|
||||||
|
mCreated = mModified;
|
||||||
mFileSystem = fs;
|
mFileSystem = fs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,6 +63,7 @@ namespace Torque
|
||||||
attr->size = mFileSize;
|
attr->size = mFileSize;
|
||||||
attr->mtime = mModified;
|
attr->mtime = mModified;
|
||||||
attr->atime = mLastAccess;
|
attr->atime = mLastAccess;
|
||||||
|
attr->ctime = mCreated;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,6 +83,7 @@ namespace Torque
|
||||||
U32 mBufferSize; // This is the size of the memory buffer >= mFileSize
|
U32 mBufferSize; // This is the size of the memory buffer >= mFileSize
|
||||||
U32 mFileSize; // This is the size of the "file" <= mBufferSize
|
U32 mFileSize; // This is the size of the "file" <= mBufferSize
|
||||||
Time mModified; // Last modified
|
Time mModified; // Last modified
|
||||||
|
Time mCreated; // When Created
|
||||||
Time mLastAccess; // Last access
|
Time mLastAccess; // Last access
|
||||||
MemFileSystem* mFileSystem;
|
MemFileSystem* mFileSystem;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,7 @@ public:
|
||||||
// use the mod time for both mod and access time, since we only have mod time in the CD
|
// use the mod time for both mod and access time, since we only have mod time in the CD
|
||||||
attr->mtime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
attr->mtime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
||||||
attr->atime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
attr->atime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
||||||
|
attr->ctime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
||||||
attr->size = mZipEntry->mCD.mUncompressedSize;
|
attr->size = mZipEntry->mCD.mUncompressedSize;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -197,6 +198,7 @@ public:
|
||||||
// use the mod time for both mod and access time, since we only have mod time in the CD
|
// use the mod time for both mod and access time, since we only have mod time in the CD
|
||||||
attr->mtime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
attr->mtime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
||||||
attr->atime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
attr->atime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
||||||
|
attr->ctime = ZipArchive::DOSTimeToTime(mZipEntry->mCD.mModTime, mZipEntry->mCD.mModDate);
|
||||||
attr->size = mZipEntry->mCD.mUncompressedSize;
|
attr->size = mZipEntry->mCD.mUncompressedSize;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -291,6 +293,7 @@ public:
|
||||||
ZipArchive::ZipEntry* zipEntry = mArchive->getRoot();
|
ZipArchive::ZipEntry* zipEntry = mArchive->getRoot();
|
||||||
attr->mtime = ZipArchive::DOSTimeToTime(zipEntry->mCD.mModTime, zipEntry->mCD.mModDate);
|
attr->mtime = ZipArchive::DOSTimeToTime(zipEntry->mCD.mModTime, zipEntry->mCD.mModDate);
|
||||||
attr->atime = ZipArchive::DOSTimeToTime(zipEntry->mCD.mModTime, zipEntry->mCD.mModDate);
|
attr->atime = ZipArchive::DOSTimeToTime(zipEntry->mCD.mModTime, zipEntry->mCD.mModDate);
|
||||||
|
attr->ctime = ZipArchive::DOSTimeToTime(zipEntry->mCD.mModTime, zipEntry->mCD.mModDate);
|
||||||
attr->size = zipEntry->mCD.mUncompressedSize;
|
attr->size = zipEntry->mCD.mUncompressedSize;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -273,6 +273,18 @@ Time FileNode::getModifiedTime()
|
||||||
return attrs.mtime;
|
return attrs.mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Time FileNode::getCreatedTime()
|
||||||
|
{
|
||||||
|
Attributes attrs;
|
||||||
|
|
||||||
|
bool success = getAttributes(&attrs);
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
return Time();
|
||||||
|
|
||||||
|
return attrs.ctime;
|
||||||
|
}
|
||||||
|
|
||||||
U64 FileNode::getSize()
|
U64 FileNode::getSize()
|
||||||
{
|
{
|
||||||
Attributes attrs;
|
Attributes attrs;
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ public:
|
||||||
String name; ///< File/Directory name
|
String name; ///< File/Directory name
|
||||||
Time mtime; ///< Last modified time
|
Time mtime; ///< Last modified time
|
||||||
Time atime; ///< Last access time
|
Time atime; ///< Last access time
|
||||||
|
Time ctime; ///< Creation Time
|
||||||
U64 size;
|
U64 size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -128,6 +129,7 @@ public:
|
||||||
|
|
||||||
// Convenience routines - may be overridden for optimal access
|
// Convenience routines - may be overridden for optimal access
|
||||||
virtual Time getModifiedTime(); ///< @note This will return Time() on failure
|
virtual Time getModifiedTime(); ///< @note This will return Time() on failure
|
||||||
|
virtual Time getCreatedTime(); ///< @note This will return Time() on failure
|
||||||
virtual U64 getSize(); ///< @note This will return 0 on failure
|
virtual U64 getSize(); ///< @note This will return 0 on failure
|
||||||
virtual U32 getChecksum(); ///< @note This will return 0 on failure
|
virtual U32 getChecksum(); ///< @note This will return 0 on failure
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ static void copyStatAttributes(const struct stat& info, FileNode::Attributes* at
|
||||||
attr->size = info.st_size;
|
attr->size = info.st_size;
|
||||||
attr->mtime = UnixTimeToTime(info.st_mtime);
|
attr->mtime = UnixTimeToTime(info.st_mtime);
|
||||||
attr->atime = UnixTimeToTime(info.st_atime);
|
attr->atime = UnixTimeToTime(info.st_atime);
|
||||||
|
attr->ctime = UnixTimeToTime(info.st_ctime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,10 @@ static void _CopyStatAttributes(const WIN32_FIND_DATAW& info, FileNode::Attribut
|
||||||
attr->atime = Win32FileTimeToTime(
|
attr->atime = Win32FileTimeToTime(
|
||||||
info.ftLastAccessTime.dwLowDateTime,
|
info.ftLastAccessTime.dwLowDateTime,
|
||||||
info.ftLastAccessTime.dwHighDateTime);
|
info.ftLastAccessTime.dwHighDateTime);
|
||||||
|
|
||||||
|
attr->ctime = Win32FileTimeToTime(
|
||||||
|
info.ftCreationTime.dwLowDateTime,
|
||||||
|
info.ftCreationTime.dwHighDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue