Core: GetFileTime, GetFileLength, FileExists, DirectoryExists functions refactored, FileMapping improved

This commit is contained in:
Mirek Fidler 2024-03-25 12:10:20 +01:00
parent f7233ea69b
commit 4a99d79cb7
6 changed files with 135 additions and 61 deletions

View file

@ -0,0 +1,40 @@
#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
String testdir = GetHomeDirFile("path_test_dir__");
DirectoryCreate(testdir);
ASSERT(DirectoryExists(testdir));
ASSERT(!FileExists(testdir));
ASSERT(!DirectoryExists(testdir + "q24312"));
String path = AppendFileName(testdir, "test.txt");
Time tm0 = GetSysTime();
SaveFile(path, "test");
ASSERT(FileExists(path));
ASSERT(!DirectoryExists(path));
ASSERT(!FileExists(path + "1"));
ASSERT(GetFileLength(path) == 4);
ASSERT(GetFileLength(path + "1") < 0);
Time tm = GetFileTime(path);
DDUMP(tm);
ASSERT(tm >= tm0 && tm <= GetSysTime());
String newpath = AppendFileName(testdir, "test2.txt");
ASSERT(FileMove(path, newpath));
ASSERT(FileExists(newpath));
ASSERT(!FileExists(path));
ASSERT(!DirectoryExists(newpath));
DeleteFolderDeep(testdir);
ASSERT(!DirectoryExists(testdir));
LOG("================== OK");
}

View file

@ -0,0 +1,9 @@
uses
Core;
file
PathOps.cpp;
mainconfig
"" = "";