mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
* BugFix: When querying against root with Torque::FS::DumpDirectories, correctly return directories with their path.
* Adjustment: Add commenting to some of the new programming. * Adjustment: Tweak fileCreatedTime and fileModifiedTime functions to use the VFS.
This commit is contained in:
parent
b63122ea76
commit
0e93373824
7 changed files with 77 additions and 34 deletions
|
|
@ -532,20 +532,20 @@ DefineEngineFunction( fileModifiedTime, String, ( const char* fileName ),,
|
||||||
"@return Formatted string (OS specific) containing modified time, \"9/3/2010 12:33:47 PM\" for example\n"
|
"@return Formatted string (OS specific) containing modified time, \"9/3/2010 12:33:47 PM\" for example\n"
|
||||||
"@ingroup FileSystem")
|
"@ingroup FileSystem")
|
||||||
{
|
{
|
||||||
Con::expandScriptFilename(sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName);
|
Torque::FS::FileNodeRef node = Torque::FS::GetFileNode(fileName);
|
||||||
|
|
||||||
FileTime ft = {0};
|
if (node)
|
||||||
Platform::getFileTimes( sgScriptFilenameBuffer, NULL, &ft );
|
{
|
||||||
|
Platform::LocalTime lt = node->getModifiedTime().toLocalTime();
|
||||||
|
|
||||||
Platform::LocalTime lt = {0};
|
String fileStr = Platform::localTimeToString(lt);
|
||||||
Platform::fileToLocalTime( ft, < );
|
|
||||||
|
char *buffer = Con::getReturnBuffer(fileStr.size());
|
||||||
String fileStr = Platform::localTimeToString( lt );
|
dStrcpy(buffer, fileStr, fileStr.size());
|
||||||
|
|
||||||
char *buffer = Con::getReturnBuffer( fileStr.size() );
|
return buffer;
|
||||||
dStrcpy( buffer, fileStr, fileStr.size() );
|
}
|
||||||
|
return "";
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineFunction( fileCreatedTime, String, ( const char* fileName ),,
|
DefineEngineFunction( fileCreatedTime, String, ( const char* fileName ),,
|
||||||
|
|
@ -555,20 +555,20 @@ DefineEngineFunction( fileCreatedTime, String, ( const char* fileName ),,
|
||||||
"@return Formatted string (OS specific) containing created time, \"9/3/2010 12:33:47 PM\" for example\n"
|
"@return Formatted string (OS specific) containing created time, \"9/3/2010 12:33:47 PM\" for example\n"
|
||||||
"@ingroup FileSystem")
|
"@ingroup FileSystem")
|
||||||
{
|
{
|
||||||
Con::expandScriptFilename( sgScriptFilenameBuffer, sizeof(sgScriptFilenameBuffer), fileName );
|
Torque::FS::FileNodeRef node = Torque::FS::GetFileNode(fileName);
|
||||||
|
|
||||||
FileTime ft = {0};
|
if (node)
|
||||||
Platform::getFileTimes( sgScriptFilenameBuffer, &ft, NULL );
|
{
|
||||||
|
Platform::LocalTime lt = node->getCreatedTime().toLocalTime();
|
||||||
|
|
||||||
Platform::LocalTime lt = {0};
|
String fileStr = Platform::localTimeToString(lt);
|
||||||
Platform::fileToLocalTime( ft, < );
|
|
||||||
|
|
||||||
String fileStr = Platform::localTimeToString( lt );
|
char *buffer = Con::getReturnBuffer(fileStr.size());
|
||||||
|
dStrcpy(buffer, fileStr, fileStr.size());
|
||||||
|
|
||||||
char *buffer = Con::getReturnBuffer( fileStr.size() );
|
return buffer;
|
||||||
dStrcpy( buffer, fileStr, fileStr.size() );
|
}
|
||||||
|
return "";
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineFunction(compareFileTimes, S32, (const char* fileA, const char* fileB), ("", ""),
|
DefineEngineFunction(compareFileTimes, S32, (const char* fileA, const char* fileB), ("", ""),
|
||||||
|
|
|
||||||
|
|
@ -195,4 +195,29 @@ void Time::get(S32 *pyear, S32 *pmonth, S32 *pday, S32 *phour, S32 *pminute, S32
|
||||||
*pmicrosecond = time % OneSecond;
|
*pmicrosecond = time % OneSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Platform::LocalTime Time::toLocalTime()
|
||||||
|
{
|
||||||
|
Platform::LocalTime result;
|
||||||
|
result.isdst = false;
|
||||||
|
|
||||||
|
S32 year;
|
||||||
|
S32 month;
|
||||||
|
S32 day;
|
||||||
|
S32 hour;
|
||||||
|
S32 minute;
|
||||||
|
S32 second;
|
||||||
|
S32 microsecond;
|
||||||
|
|
||||||
|
get(&year, &month, &day, &hour, &minute, &second, µsecond);
|
||||||
|
result.year = year - 1900;
|
||||||
|
result.month = month - 1;
|
||||||
|
result.yearday = day;
|
||||||
|
result.hour = hour;
|
||||||
|
result.min = minute;
|
||||||
|
result.sec = second;
|
||||||
|
result.monthday = day % 32;
|
||||||
|
result.weekday = day % 7;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,9 @@
|
||||||
#ifndef _TORQUE_TYPES_H_
|
#ifndef _TORQUE_TYPES_H_
|
||||||
#include "platform/types.h"
|
#include "platform/types.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _PLATFORM_H_
|
||||||
|
#include "platform/platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(TORQUE_COMPILER_VISUALC)
|
#if defined(TORQUE_COMPILER_VISUALC)
|
||||||
#define TORQUE_CONSTANT_S64(a) (a##I64)
|
#define TORQUE_CONSTANT_S64(a) (a##I64)
|
||||||
|
|
@ -105,6 +107,8 @@ public:
|
||||||
S64 getMicroseconds() const;
|
S64 getMicroseconds() const;
|
||||||
S64 getInternalRepresentation() const;
|
S64 getInternalRepresentation() const;
|
||||||
|
|
||||||
|
Platform::LocalTime toLocalTime();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Tester
|
class Tester
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -600,17 +600,24 @@ bool MountSystem::_dumpDirectories(DirectoryRef directory, Vector<StringTableEnt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Queries against / will return a directory count of 1, but the code relies on actual directory entries (Eg. /data) so we handle that special case
|
||||||
|
const U32 basePathDirectoryCount = String::compare(basePath.getFullPathWithoutRoot(), "/") == 0 ? basePath.getDirectoryCount() - 1 : basePath.getDirectoryCount();
|
||||||
|
|
||||||
for (U32 iteration = 0; iteration < directoryPaths.size(); ++iteration)
|
for (U32 iteration = 0; iteration < directoryPaths.size(); ++iteration)
|
||||||
{
|
{
|
||||||
const Path& directoryPath = directoryPaths[iteration];
|
const Path& directoryPath = directoryPaths[iteration];
|
||||||
|
|
||||||
|
// Load the full path to the directory unless we're not supposed to include base paths
|
||||||
String directoryPathString = directoryPath.getFullPath().c_str();
|
String directoryPathString = directoryPath.getFullPath().c_str();
|
||||||
if (noBasePath)
|
if (noBasePath)
|
||||||
{
|
{
|
||||||
|
// Build a path representing the directory tree *after* the base path query but excluding the base
|
||||||
|
// So if we queried for data/ and are currently processing data/ExampleModule/datablocks we want to output
|
||||||
|
// ExampleModule/datablocks
|
||||||
Path newDirectoryPath;
|
Path newDirectoryPath;
|
||||||
for (U32 iteration = basePath.getDirectoryCount(); iteration < directoryPath.getDirectoryCount(); ++iteration)
|
for (U32 iteration = basePathDirectoryCount; iteration < directoryPath.getDirectoryCount(); ++iteration)
|
||||||
{
|
{
|
||||||
if (iteration > basePath.getDirectoryCount())
|
if (iteration > basePathDirectoryCount)
|
||||||
{
|
{
|
||||||
newDirectoryPath.setPath(newDirectoryPath.getPath() + "/");
|
newDirectoryPath.setPath(newDirectoryPath.getPath() + "/");
|
||||||
}
|
}
|
||||||
|
|
@ -622,6 +629,7 @@ bool MountSystem::_dumpDirectories(DirectoryRef directory, Vector<StringTableEnt
|
||||||
directoryPathString = newDirectoryPath.getFullPathWithoutRoot();
|
directoryPathString = newDirectoryPath.getFullPathWithoutRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output result and enumerate subdirectories if we're not too deep according to the depth parameter
|
||||||
directories.push_back(StringTable->insert(directoryPathString, true));
|
directories.push_back(StringTable->insert(directoryPathString, true));
|
||||||
if (currentDepth <= depth)
|
if (currentDepth <= depth)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,7 @@ bool MountDefaults()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef TORQUE_SECURE_VFS
|
#ifdef TORQUE_SECURE_VFS
|
||||||
// Set working directory to where the executable is
|
mounted = Mount("/", createNativeFS(path));
|
||||||
StringTableEntry executablePath = Platform::getExecutablePath();
|
|
||||||
SetCwd(executablePath);
|
|
||||||
|
|
||||||
// FIXME: Should we use the asset path here as well?
|
|
||||||
mounted = Mount("/", createNativeFS(executablePath));
|
|
||||||
if (!mounted)
|
if (!mounted)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,7 @@ PlatformWindowManagerSDL::DragAndDropFSInfo::DragAndDropFSInfo(String rootName,
|
||||||
|
|
||||||
PlatformWindowManagerSDL::DragAndDropFSInfo::~DragAndDropFSInfo()
|
PlatformWindowManagerSDL::DragAndDropFSInfo::~DragAndDropFSInfo()
|
||||||
{
|
{
|
||||||
// FIXME: Cleanup - we can't simply do this unmount due to the way the hash mapping works
|
|
||||||
// Torque::FS::Unmount(mDragAndDropFS);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -88,6 +87,15 @@ PlatformWindowManagerSDL::PlatformWindowManagerSDL()
|
||||||
|
|
||||||
PlatformWindowManagerSDL::~PlatformWindowManagerSDL()
|
PlatformWindowManagerSDL::~PlatformWindowManagerSDL()
|
||||||
{
|
{
|
||||||
|
// Unmount all drag and drop FS mounts
|
||||||
|
for (auto iteration = mActiveDragAndDropFSByPath.begin(); iteration != mActiveDragAndDropFSByPath.end(); ++iteration)
|
||||||
|
{
|
||||||
|
auto&& mapping = *iteration;
|
||||||
|
Torque::FS::Unmount(mapping.value.mDragAndDropFS);
|
||||||
|
}
|
||||||
|
mActiveDragAndDropByRoot.clear();
|
||||||
|
mActiveDragAndDropFSByPath.clear();
|
||||||
|
|
||||||
// Kill all our windows first.
|
// Kill all our windows first.
|
||||||
while(mWindowListHead)
|
while(mWindowListHead)
|
||||||
// The destructors update the list, so this works just fine.
|
// The destructors update the list, so this works just fine.
|
||||||
|
|
@ -473,7 +481,7 @@ void PlatformWindowManagerSDL::_process()
|
||||||
while (search != mActiveDragAndDropByRoot.end())
|
while (search != mActiveDragAndDropByRoot.end())
|
||||||
{
|
{
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
dSprintf(buffer, 32, "%u", rootCounter);
|
dSprintf(buffer, sizeof(buffer), "%u", rootCounter);
|
||||||
chosenRootName = directoryName + buffer;
|
chosenRootName = directoryName + buffer;
|
||||||
|
|
||||||
search = mActiveDragAndDropByRoot.find(chosenRootName);
|
search = mActiveDragAndDropByRoot.find(chosenRootName);
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,10 @@ protected:
|
||||||
KeyboardInputState mInputState;
|
KeyboardInputState mInputState;
|
||||||
|
|
||||||
#ifdef TORQUE_SECURE_VFS
|
#ifdef TORQUE_SECURE_VFS
|
||||||
|
/// Used to check if a root is already used when generating root names.
|
||||||
HashMap<String, DragAndDropFSInfo> mActiveDragAndDropByRoot;
|
HashMap<String, DragAndDropFSInfo> mActiveDragAndDropByRoot;
|
||||||
|
|
||||||
|
/// Used to keep track of what mounts are handling a given path.
|
||||||
HashMap<Torque::Path, DragAndDropFSInfo> mActiveDragAndDropFSByPath;
|
HashMap<Torque::Path, DragAndDropFSInfo> mActiveDragAndDropFSByPath;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue