mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
* Feature: Initial secure VFS implementation with asset import capability.
This commit is contained in:
parent
d9bedbe31c
commit
277cdf67b0
12 changed files with 220 additions and 10 deletions
|
|
@ -500,6 +500,28 @@ Path MountSystem::_normalize(const Path& path)
|
|||
return po;
|
||||
}
|
||||
|
||||
bool MountSystem::copyFile(const Path& source, const Path& destination, bool noOverwrite)
|
||||
{
|
||||
// Exit out early if we're not overriding
|
||||
if (isFile(destination) && noOverwrite)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
FileRef sourceFile = openFile(source, FS::File::AccessMode::Read);
|
||||
const U64 sourceFileSize = sourceFile->getSize();
|
||||
|
||||
void* writeBuffer = dMalloc(sourceFileSize);
|
||||
sourceFile->read(writeBuffer, sourceFileSize);
|
||||
|
||||
FileRef destinationFile = openFile(destination, FS::File::AccessMode::Write);
|
||||
const bool success = destinationFile->write(writeBuffer, sourceFileSize) == sourceFileSize;
|
||||
|
||||
dFree(writeBuffer);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
FileRef MountSystem::createFile(const Path& path)
|
||||
{
|
||||
Path np = _normalize(path);
|
||||
|
|
@ -909,6 +931,11 @@ FileRef CreateFile(const Path &path)
|
|||
return sgMountSystem.createFile(path);
|
||||
}
|
||||
|
||||
bool CopyFile(const Path& source, const Path& destination, bool noOverwrite)
|
||||
{
|
||||
return sgMountSystem.copyFile(source, destination, noOverwrite);
|
||||
}
|
||||
|
||||
DirectoryRef CreateDirectory(const Path &path)
|
||||
{
|
||||
return sgMountSystem.createDirectory(path);
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ public:
|
|||
virtual ~MountSystem() {}
|
||||
|
||||
FileRef createFile(const Path& path);
|
||||
bool copyFile(const Path& source, const Path& destination, bool noOverwrite);
|
||||
DirectoryRef createDirectory(const Path& path, FileSystemRef fs = NULL);
|
||||
virtual bool createPath(const Path& path);
|
||||
|
||||
|
|
@ -538,6 +539,9 @@ DirectoryRef OpenDirectory(const Path &file);
|
|||
///@ingroup VolumeSystem
|
||||
FileRef CreateFile(const Path &file);
|
||||
|
||||
/// Copy a file from one location to another.
|
||||
bool CopyFile(const Path& source, const Path& destination, bool noOverride);
|
||||
|
||||
/// Create a directory.
|
||||
/// The directory object is returned in a closed state.
|
||||
///@ingroup VolumeSystem
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue