mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Core: GetFileTime, GetFileLength, FileExists, DirectoryExists functions refactored, FileMapping improved
This commit is contained in:
parent
f7233ea69b
commit
4a99d79cb7
6 changed files with 135 additions and 61 deletions
40
autotest/PathOps/PathOps.cpp
Normal file
40
autotest/PathOps/PathOps.cpp
Normal 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");
|
||||
}
|
||||
9
autotest/PathOps/PathOps.upp
Normal file
9
autotest/PathOps/PathOps.upp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
uses
|
||||
Core;
|
||||
|
||||
file
|
||||
PathOps.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue