* Adjustment: Change several filesystem functions to use the VFS.

* Feature: Initial implementation of a VFS dump directories function.
This commit is contained in:
Robert MacGregor 2021-12-18 23:37:49 -05:00
parent 948bc43d85
commit cbe7ee13d6
5 changed files with 130 additions and 42 deletions

View file

@ -368,15 +368,11 @@ DefineEngineFunction(getFileCRC, S32, ( const char* fileName ),,
"@ingroup FileSystem")
{
String cleanfilename(Torque::Path::CleanSeparators(fileName));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), cleanfilename.c_str());
Torque::Path givenPath(Torque::Path::CompressPath(sgScriptFilenameBuffer));
Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode( givenPath );
Torque::FS::FileNodeRef fileRef = Torque::FS::GetFileNode( fileName );
if ( fileRef == NULL )
{
Con::errorf("getFileCRC() - could not access file: [%s]", givenPath.getFullPath().c_str() );
Con::errorf("getFileCRC() - could not access file: [%s]", fileName );
return -1;
}
@ -391,11 +387,7 @@ DefineEngineFunction(isFile, bool, ( const char* fileName ),,
"@ingroup FileSystem")
{
String cleanfilename(Torque::Path::CleanSeparators(fileName));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), cleanfilename.c_str());
Torque::Path givenPath(Torque::Path::CompressPath(sgScriptFilenameBuffer));
return Torque::FS::IsFile(givenPath);
return Torque::FS::IsFile(fileName);
}
DefineEngineFunction(isScriptFile, bool, (const char* fileName), ,
@ -406,11 +398,7 @@ DefineEngineFunction(isScriptFile, bool, (const char* fileName), ,
"@ingroup FileSystem")
{
String cleanfilename(Torque::Path::CleanSeparators(fileName));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), cleanfilename.c_str());
Torque::Path givenPath(Torque::Path::CompressPath(sgScriptFilenameBuffer));
return Torque::FS::IsScriptFile(givenPath.getFullPath());
return Torque::FS::IsScriptFile(fileName);
}
DefineEngineFunction( IsDirectory, bool, ( const char* directory ),,
@ -423,11 +411,7 @@ DefineEngineFunction( IsDirectory, bool, ( const char* directory ),,
"@ingroup FileSystem")
{
String dir(Torque::Path::CleanSeparators(directory));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), dir.c_str());
Torque::Path givenPath(Torque::Path::CompressPath(sgScriptFilenameBuffer));
return Torque::FS::IsDirectory( givenPath );
return Torque::FS::IsDirectory( directory );
}
DefineEngineFunction(isWriteableFileName, bool, ( const char* fileName ),,
@ -438,14 +422,7 @@ DefineEngineFunction(isWriteableFileName, bool, ( const char* fileName ),,
"@ingroup FileSystem")
{
String filename(Torque::Path::CleanSeparators(fileName));
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), filename.c_str());
Torque::Path givenPath(Torque::Path::CompressPath(sgScriptFilenameBuffer));
Torque::FS::FileSystemRef fs = Torque::FS::GetFileSystem(givenPath);
Torque::Path path = fs->mapTo(givenPath);
return !Torque::FS::IsReadOnly(path);
return !Torque::FS::IsReadOnly(fileName);
}
DefineEngineFunction(startFileChangeNotifications, void, (),,
@ -840,7 +817,11 @@ DefineEngineFunction( getCurrentDirectory, String, (),,
"@see getWorkingDirectory()"
"@ingroup FileSystem")
{
#ifdef TORQUE_SECURE_VFS
return Torque::FS::GetCwd();
#else
return Platform::getCurrentDirectory();
#endif
}
//-----------------------------------------------------------------------------
@ -853,8 +834,11 @@ DefineEngineFunction( setCurrentDirectory, bool, ( const char* path ),,
"@note Only present in a Tools build of Torque.\n"
"@ingroup FileSystem")
{
#ifdef TORQUE_SECURE_VFS
return Torque::FS::SetCwd(path);
#else
return Platform::setCurrentDirectory( StringTable->insert( path ) );
#endif
}
//-----------------------------------------------------------------------------