mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
More WIP on moving to taking native paths
This commit is contained in:
parent
7899dd51d5
commit
932fca0b0b
@ -99,6 +99,7 @@ void Chat_DisableLogging(void) {
|
|||||||
|
|
||||||
static cc_bool CreateLogsDirectory(void) {
|
static cc_bool CreateLogsDirectory(void) {
|
||||||
static const cc_string dir = String_FromConst("logs");
|
static const cc_string dir = String_FromConst("logs");
|
||||||
|
cc_filepath str;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
/* Utils_EnsureDirectory cannot be used here because it causes a stack overflow */
|
/* Utils_EnsureDirectory cannot be used here because it causes a stack overflow */
|
||||||
/* when running the game and an error occurs when trying to create the directory */
|
/* when running the game and an error occurs when trying to create the directory */
|
||||||
@ -111,7 +112,8 @@ static cc_bool CreateLogsDirectory(void) {
|
|||||||
/* --> Utils_EnsureDirectory --> Logger_SysWarn2 --> Chat_Add --> AppendChatLog -> OpenChatLog */
|
/* --> Utils_EnsureDirectory --> Logger_SysWarn2 --> Chat_Add --> AppendChatLog -> OpenChatLog */
|
||||||
/* --> Utils_EnsureDirectory --> Logger_SysWarn2 --> Chat_Add --> AppendChatLog ... */
|
/* --> Utils_EnsureDirectory --> Logger_SysWarn2 --> Chat_Add --> AppendChatLog ... */
|
||||||
/* and so on, until eventually the stack overflows */
|
/* and so on, until eventually the stack overflows */
|
||||||
res = Directory_Create(&dir);
|
Platform_EncodePath(&str, &dir);
|
||||||
|
res = Directory_Create(&str);
|
||||||
if (!res || res == ReturnCode_DirectoryExists) return true;
|
if (!res || res == ReturnCode_DirectoryExists) return true;
|
||||||
|
|
||||||
Chat_DisableLogging();
|
Chat_DisableLogging();
|
||||||
|
@ -192,7 +192,7 @@ CC_API cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end);
|
|||||||
int Stopwatch_ElapsedMS(cc_uint64 beg, cc_uint64 end);
|
int Stopwatch_ElapsedMS(cc_uint64 beg, cc_uint64 end);
|
||||||
|
|
||||||
/* Attempts to create a new directory. */
|
/* Attempts to create a new directory. */
|
||||||
CC_API cc_result Directory_Create(const cc_string* path);
|
cc_result Directory_Create(cc_filepath_ptr path);
|
||||||
/* Callback function invoked for each file found. */
|
/* Callback function invoked for each file found. */
|
||||||
typedef void (*Directory_EnumCallback)(const cc_string* filename, void* obj, int isDirectory);
|
typedef void (*Directory_EnumCallback)(const cc_string* filename, void* obj, int isDirectory);
|
||||||
/* Invokes a callback function on all filenames in the given directory (and its sub-directories) */
|
/* Invokes a callback function on all filenames in the given directory (and its sub-directories) */
|
||||||
@ -203,11 +203,11 @@ void Directory_GetCachePath(cc_string* path);
|
|||||||
|
|
||||||
/* Attempts to create a new (or overwrite) file for writing. */
|
/* Attempts to create a new (or overwrite) file for writing. */
|
||||||
/* NOTE: If the file already exists, its contents are discarded. */
|
/* NOTE: If the file already exists, its contents are discarded. */
|
||||||
cc_result File_Create(cc_file* file, const cc_filepath_ptr path);
|
cc_result File_Create(cc_file* file, cc_filepath_ptr path);
|
||||||
/* Attempts to open an existing file for reading. */
|
/* Attempts to open an existing file for reading. */
|
||||||
cc_result File_Open(cc_file* file, const cc_filepath_ptr path);
|
cc_result File_Open(cc_file* file, cc_filepath_ptr path);
|
||||||
/* Attempts to open an existing or create a new file for reading and writing. */
|
/* Attempts to open an existing or create a new file for reading and writing. */
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const cc_filepath_ptr path);
|
cc_result File_OpenOrCreate(cc_file* file, cc_filepath_ptr path);
|
||||||
/* Attempts to read data from the file. */
|
/* Attempts to read data from the file. */
|
||||||
cc_result File_Read(cc_file file, void* data, cc_uint32 count, cc_uint32* bytesRead);
|
cc_result File_Read(cc_file file, void* data, cc_uint32 count, cc_uint32* bytesRead);
|
||||||
/* Attempts to write data to the file. */
|
/* Attempts to write data to the file. */
|
||||||
|
@ -97,11 +97,8 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
return mkdir(path, 0666) == -1 ? errno : 0; // FS has no permissions anyways
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
|
|
||||||
return mkdir(str, 0666) == -1 ? errno : 0; // FS has no permissions anyways
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -152,13 +149,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,11 +193,8 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
int res = fs_mkdir(path);
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
|
|
||||||
int res = fs_mkdir(str);
|
|
||||||
int err = res == -1 ? errno : 0;
|
int err = res == -1 ? errno : 0;
|
||||||
|
|
||||||
// Filesystem returns EINVAL when operation unsupported (e.g. CD system)
|
// Filesystem returns EINVAL when operation unsupported (e.g. CD system)
|
||||||
@ -252,7 +249,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
static cc_result File_Do(cc_file* file, char* path, int mode) {
|
||||||
// CD filesystem loader doesn't usually set errno
|
// CD filesystem loader doesn't usually set errno
|
||||||
// when it can't find the requested file
|
// when it can't find the requested file
|
||||||
errno = 0;
|
errno = 0;
|
||||||
@ -271,13 +268,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,12 +126,10 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
if (!fat_available) return ENOSYS;
|
if (!fat_available) return ENOSYS;
|
||||||
|
|
||||||
cc_filepath str;;
|
return mkdir(path, 0) == -1 ? errno : 0;
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
return mkdir(str, 0) == -1 ? errno : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -183,22 +181,22 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
static cc_result File_Do(cc_file* file, char* path, int mode) {
|
||||||
*file = open(path, mode, 0);
|
*file = open(path, mode, 0);
|
||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
if (!fat_available) return ReturnCode_FileNotFound;
|
if (!fat_available) return ReturnCode_FileNotFound;
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
if (!fat_available) return ENOTSUP;
|
if (!fat_available) return ENOTSUP;
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
if (!fat_available) return ENOTSUP;
|
if (!fat_available) return ENOTSUP;
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
}
|
}
|
||||||
|
@ -231,10 +231,8 @@ static int DoCreateFolder(char* name) {
|
|||||||
|
|
||||||
void Directory_GetCachePath(cc_string* path) { }
|
void Directory_GetCachePath(cc_string* path) { }
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
char buffer[NATIVE_STR_LEN];
|
return DoCreateFolder(path);
|
||||||
Platform_EncodePath(buffer, path);
|
|
||||||
return DoCreateFolder(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -248,18 +246,18 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return DoOpenDF(path, fsRdPerm, file);
|
return DoOpenDF(path, fsRdPerm, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
int res = DoCreateFile(path);
|
int res = DoCreateFile(path);
|
||||||
if (res && res != dupFNErr) return res;
|
if (res && res != dupFNErr) return res;
|
||||||
|
|
||||||
return DoOpenDF(path, fsWrPerm, file);
|
return DoOpenDF(path, fsWrPerm, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const cc_string* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
int res = DoCreateFile(path);
|
int res = DoCreateFile(path);
|
||||||
if (res && res != dupFNErr) return res;
|
if (res && res != dupFNErr) return res;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, &path_);
|
String_EncodeUtf8(str, &path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
return ERR_NOT_SUPPORTED; // TODO add support
|
return ERR_NOT_SUPPORTED; // TODO add support
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_result File_Do(cc_file* file, const char* path) {
|
static cc_result File_Do(cc_file* file, char* path) {
|
||||||
//*file = -1;
|
//*file = -1;
|
||||||
//return ReturnCode_FileNotFound;
|
//return ReturnCode_FileNotFound;
|
||||||
// TODO: Why does trying this code break everything
|
// TODO: Why does trying this code break everything
|
||||||
@ -106,15 +106,15 @@ static cc_result File_Do(cc_file* file, const char* path) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path);
|
return File_Do(file, path);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
*file = -1;
|
*file = -1;
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
//return File_Do(file, path);
|
//return File_Do(file, path);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
*file = -1;
|
*file = -1;
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
//return File_Do(file, path);
|
//return File_Do(file, path);
|
||||||
|
@ -115,14 +115,11 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
if (!fat_available) return 0;
|
if (!fat_available) return 0;
|
||||||
|
|
||||||
cc_filepath str;
|
Platform_Log1("mkdir %c", path);
|
||||||
Platform_EncodePath(str, path);
|
return mkdir(path, 0) == -1 ? errno : 0;
|
||||||
Platform_Log1("mkdir %c", str);
|
|
||||||
|
|
||||||
return mkdir(str, 0) == -1 ? errno : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -173,24 +170,24 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_result File_Do(cc_file* file, const char* path, int mode, const char* type) {
|
static cc_result File_Do(cc_file* file, char* path, int mode, const char* type) {
|
||||||
Platform_Log2("%c %c", type, path);
|
Platform_Log2("%c %c", type, path);
|
||||||
|
|
||||||
*file = open(path, mode, 0);
|
*file = open(path, mode, 0);
|
||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
if (!fat_available) return ReturnCode_FileNotFound;
|
if (!fat_available) return ReturnCode_FileNotFound;
|
||||||
return File_Do(file, path, O_RDONLY, "Open");
|
return File_Do(file, path, O_RDONLY, "Open");
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
if (!fat_available) return ENOTSUP;
|
if (!fat_available) return ENOTSUP;
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC, "Create");
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC, "Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
if (!fat_available) return ENOTSUP;
|
if (!fat_available) return ENOTSUP;
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT, "Update");
|
return File_Do(file, path, O_RDWR | O_CREAT, "Update");
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,11 +109,11 @@ cc_result File_Open(cc_file* file, const char* path) {
|
|||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,10 +113,8 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
return fioMkdir(path);
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
return fioMkdir(str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -180,13 +178,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return res < 0 ? res : 0;
|
return res < 0 ? res : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, FIO_O_RDONLY);
|
return File_Do(file, path, FIO_O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, FIO_O_RDWR | FIO_O_CREAT | FIO_O_TRUNC);
|
return File_Do(file, path, FIO_O_RDWR | FIO_O_CREAT | FIO_O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, FIO_O_RDWR | FIO_O_CREAT);
|
return File_Do(file, path, FIO_O_RDWR | FIO_O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,12 +101,10 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
||||||
/* TODO: Is the default mode in all cases */
|
/* TODO: Is the default mode in all cases */
|
||||||
return sysLv2FsMkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
return sysLv2FsMkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -166,13 +164,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, SYS_O_RDONLY);
|
return File_Do(file, path, SYS_O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, SYS_O_RDWR | SYS_O_CREAT | SYS_O_TRUNC);
|
return File_Do(file, path, SYS_O_RDWR | SYS_O_CREAT | SYS_O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, SYS_O_RDWR | SYS_O_CREAT);
|
return File_Do(file, path, SYS_O_RDWR | SYS_O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,8 +444,7 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
|||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
netInitialize();
|
netInitialize();
|
||||||
// Create root directory
|
Directory_Create(root_path.buffer);
|
||||||
Directory_Create(&String_Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_Free(void) { }
|
void Platform_Free(void) { }
|
||||||
|
@ -94,10 +94,7 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
|
|
||||||
#define GetSCEResult(result) (result >= 0 ? 0 : result & 0xFFFF)
|
#define GetSCEResult(result) (result >= 0 ? 0 : result & 0xFFFF)
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
|
|
||||||
int result = sceIoMkdir(str, 0777);
|
int result = sceIoMkdir(str, 0777);
|
||||||
return GetSCEResult(result);
|
return GetSCEResult(result);
|
||||||
}
|
}
|
||||||
@ -147,13 +144,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return GetSCEResult(result);
|
return GetSCEResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, PSP_O_RDONLY);
|
return File_Do(file, path, PSP_O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, PSP_O_RDWR | PSP_O_CREAT | PSP_O_TRUNC);
|
return File_Do(file, path, PSP_O_RDWR | PSP_O_CREAT | PSP_O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, PSP_O_RDWR | PSP_O_CREAT);
|
return File_Do(file, path, PSP_O_RDWR | PSP_O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,8 +429,7 @@ void Platform_Init(void) {
|
|||||||
// TODO: work out why this error is actually happening (inexact or underflow?) and properly fix it
|
// TODO: work out why this error is actually happening (inexact or underflow?) and properly fix it
|
||||||
pspSdkDisableFPUExceptions();
|
pspSdkDisableFPUExceptions();
|
||||||
|
|
||||||
// Create root directory
|
Directory_Create(root_path.buffer);
|
||||||
Directory_Create(&String_Empty);
|
|
||||||
}
|
}
|
||||||
void Platform_Free(void) { }
|
void Platform_Free(void) { }
|
||||||
|
|
||||||
|
@ -77,11 +77,8 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
|
|
||||||
#define GetSCEResult(result) (result >= 0 ? 0 : result & 0xFFFF)
|
#define GetSCEResult(result) (result >= 0 ? 0 : result & 0xFFFF)
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
int result = sceIoMkdir(path, 0777);
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
|
|
||||||
int result = sceIoMkdir(str, 0777);
|
|
||||||
return GetSCEResult(result);
|
return GetSCEResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,13 +127,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return GetSCEResult(result);
|
return GetSCEResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, SCE_O_RDONLY);
|
return File_Do(file, path, SCE_O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, SCE_O_RDWR | SCE_O_CREAT | SCE_O_TRUNC);
|
return File_Do(file, path, SCE_O_RDWR | SCE_O_CREAT | SCE_O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, SCE_O_RDWR | SCE_O_CREAT);
|
return File_Do(file, path, SCE_O_RDWR | SCE_O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,8 +385,7 @@ void Platform_Init(void) {
|
|||||||
/*pspDebugSioInit();*/
|
/*pspDebugSioInit();*/
|
||||||
InitNetworking();
|
InitNetworking();
|
||||||
epoll_id = sceNetEpollCreate("CC poll", 0);
|
epoll_id = sceNetEpollCreate("CC poll", 0);
|
||||||
// Create root directory
|
Directory_Create(root_path.buffer);
|
||||||
Directory_Create(&String_Empty);
|
|
||||||
}
|
}
|
||||||
void Platform_Free(void) { }
|
void Platform_Free(void) { }
|
||||||
|
|
||||||
|
@ -201,12 +201,10 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
void Directory_GetCachePath(cc_string* path) { }
|
void Directory_GetCachePath(cc_string* path) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
||||||
/* TODO: Is the default mode in all cases */
|
/* TODO: Is the default mode in all cases */
|
||||||
return mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
|
return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -272,21 +270,21 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
#if !defined CC_BUILD_OS2
|
#if !defined CC_BUILD_OS2
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
#else
|
#else
|
||||||
return File_Do(file, path, O_RDONLY | O_BINARY);
|
return File_Do(file, path, O_RDONLY | O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
#if !defined CC_BUILD_OS2
|
#if !defined CC_BUILD_OS2
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
#else
|
#else
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
#if !defined CC_BUILD_OS2
|
#if !defined CC_BUILD_OS2
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
#else
|
#else
|
||||||
|
@ -89,7 +89,7 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,15 +101,15 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return ERR_NOT_SUPPORTED;
|
return ERR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,10 +115,8 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
return mkdir(path, 0) == -1 ? errno : 0;
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
return mkdir(str, 0) == -1 ? errno : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -171,13 +169,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
void Directory_GetCachePath(cc_string* path) { }
|
void Directory_GetCachePath(cc_string* path) { }
|
||||||
|
|
||||||
extern void interop_InitFilesystem(void);
|
extern void interop_InitFilesystem(void);
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
/* Web filesystem doesn't need directories */
|
/* Web filesystem doesn't need directories */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -152,13 +152,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +109,10 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;
|
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
||||||
/* TODO: Is the default mode in all cases */
|
/* TODO: Is the default mode in all cases */
|
||||||
return mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
|
return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
|
@ -184,16 +184,13 @@ void Platform_EncodePath(cc_filepath_ptr dst, const cc_string* src) {
|
|||||||
Platform_EncodeString(dst, src);
|
Platform_EncodeString(dst, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(cc_filepath_ptr path) {
|
||||||
cc_filepath str;
|
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
if (CreateDirectoryW(path->uni, NULL)) return 0;
|
||||||
Platform_EncodePath(&str, path);
|
|
||||||
if (CreateDirectoryW(str.uni, NULL)) return 0;
|
|
||||||
/* Windows 9x does not support W API functions */
|
/* Windows 9x does not support W API functions */
|
||||||
if ((res = GetLastError()) != ERROR_CALL_NOT_IMPLEMENTED) return res;
|
if ((res = GetLastError()) != ERROR_CALL_NOT_IMPLEMENTED) return res;
|
||||||
|
|
||||||
return CreateDirectoryA(str.ansi, NULL) ? 0 : GetLastError();
|
return CreateDirectoryA(path->ansi, NULL) ? 0 : GetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -283,13 +280,13 @@ static cc_result DoFile(cc_file* file, const cc_filepath* path, DWORD access, DW
|
|||||||
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
|
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const cc_filepath_ptr path) {
|
cc_result File_Open(cc_file* file, cc_filepath_ptr path) {
|
||||||
return DoFile(file, path, GENERIC_READ, OPEN_EXISTING);
|
return DoFile(file, path, GENERIC_READ, OPEN_EXISTING);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const cc_filepath_ptr path) {
|
cc_result File_Create(cc_file* file, cc_filepath_ptr path) {
|
||||||
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS);
|
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const cc_filepath_ptr path) {
|
cc_result File_OpenOrCreate(cc_file* file, cc_filepath_ptr path) {
|
||||||
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, OPEN_ALWAYS);
|
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, OPEN_ALWAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,14 +100,10 @@ void Platform_EncodePath(char* str, const cc_string* src) {
|
|||||||
*str = '\0';
|
*str = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
if (!hdd_mounted) return ERR_NOT_SUPPORTED;
|
if (!hdd_mounted) return ERR_NOT_SUPPORTED;
|
||||||
|
|
||||||
cc_filepath str;
|
return CreateDirectoryA(path, NULL) ? 0 : GetLastError();
|
||||||
cc_result res;
|
|
||||||
|
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
return CreateDirectoryA(str, NULL) ? 0 : GetLastError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -172,17 +168,17 @@ static cc_result DoFile(cc_file* file, const char* path, DWORD access, DWORD cre
|
|||||||
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
|
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
if (!hdd_mounted) return ReturnCode_FileNotFound;
|
if (!hdd_mounted) return ReturnCode_FileNotFound;
|
||||||
return DoFile(file, path, GENERIC_READ, OPEN_EXISTING);
|
return DoFile(file, path, GENERIC_READ, OPEN_EXISTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
if (!hdd_mounted) return ERR_NOT_SUPPORTED;
|
if (!hdd_mounted) return ERR_NOT_SUPPORTED;
|
||||||
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS);
|
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, CREATE_ALWAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
if (!hdd_mounted) return ERR_NOT_SUPPORTED;
|
if (!hdd_mounted) return ERR_NOT_SUPPORTED;
|
||||||
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, OPEN_ALWAYS);
|
return DoFile(file, path, GENERIC_WRITE | GENERIC_READ, OPEN_ALWAYS);
|
||||||
}
|
}
|
||||||
@ -415,7 +411,7 @@ static void InitHDD(void) {
|
|||||||
Platform_LogConst("Failed to mount E:/ from Data partition");
|
Platform_LogConst("Failed to mount E:/ from Data partition");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Directory_Create(&String_Empty); // create root ClassiCube folder
|
Directory_Create(root_path.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_Init(void) {
|
void Platform_Init(void) {
|
||||||
|
@ -84,10 +84,8 @@ void Platform_EncodePath(char* str, const cc_string* path) {
|
|||||||
String_EncodeUtf8(str, path);
|
String_EncodeUtf8(str, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(char* path) {
|
||||||
cc_filepath str;;
|
return mkdir(path, 0) == -1 ? errno : 0;
|
||||||
Platform_EncodePath(str, path);
|
|
||||||
return mkdir(str, 0) == -1 ? errno : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
@ -140,13 +138,13 @@ static cc_result File_Do(cc_file* file, const char* path, int mode) {
|
|||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result File_Open(cc_file* file, const char* path) {
|
cc_result File_Open(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDONLY);
|
return File_Do(file, path, O_RDONLY);
|
||||||
}
|
}
|
||||||
cc_result File_Create(cc_file* file, const char* path) {
|
cc_result File_Create(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
return File_Do(file, path, O_RDWR | O_CREAT | O_TRUNC);
|
||||||
}
|
}
|
||||||
cc_result File_OpenOrCreate(cc_file* file, const char* path) {
|
cc_result File_OpenOrCreate(cc_file* file, char* path) {
|
||||||
return File_Do(file, path, O_RDWR | O_CREAT);
|
return File_Do(file, path, O_RDWR | O_CREAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,11 +255,13 @@ CC_INLINE static void HashUrl(cc_string* key, const cc_string* url) {
|
|||||||
static cc_bool createdCache, cacheInvalid;
|
static cc_bool createdCache, cacheInvalid;
|
||||||
static cc_bool UseDedicatedCache(cc_string* path, const cc_string* key) {
|
static cc_bool UseDedicatedCache(cc_string* path, const cc_string* key) {
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
cc_filepath str;
|
||||||
Directory_GetCachePath(path);
|
Directory_GetCachePath(path);
|
||||||
if (!path->length || cacheInvalid) return false;
|
if (!path->length || cacheInvalid) return false;
|
||||||
|
|
||||||
String_AppendConst(path, "/texturecache");
|
String_AppendConst(path, "/texturecache");
|
||||||
res = Directory_Create(path);
|
Platform_EncodePath(&str, path);
|
||||||
|
res = Directory_Create(&str);
|
||||||
|
|
||||||
/* Check if something is deleting the cache directory behind our back */
|
/* Check if something is deleting the cache directory behind our back */
|
||||||
/* (Several users have reported this happening on some Android devices) */
|
/* (Several users have reported this happening on some Android devices) */
|
||||||
|
@ -24,8 +24,13 @@ cc_bool Utils_IsUrlPrefix(const cc_string* value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Utils_EnsureDirectory(const char* dirName) {
|
cc_bool Utils_EnsureDirectory(const char* dirName) {
|
||||||
cc_string dir = String_FromReadonly(dirName);
|
cc_filepath path;
|
||||||
cc_result res = Directory_Create(&dir);
|
cc_string dir;
|
||||||
|
cc_result res;
|
||||||
|
|
||||||
|
dir = String_FromReadonly(dirName);
|
||||||
|
Platform_EncodePath(&path, &dir);
|
||||||
|
res = Directory_Create(&path);
|
||||||
|
|
||||||
if (!res || res == ReturnCode_DirectoryExists) return true;
|
if (!res || res == ReturnCode_DirectoryExists) return true;
|
||||||
Logger_SysWarn2(res, "creating directory", &dir);
|
Logger_SysWarn2(res, "creating directory", &dir);
|
||||||
|
@ -450,12 +450,11 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* save_args) {
|
|||||||
if (!save_args->defaultName.length) return SFD_ERR_NEED_DEFAULT_NAME;
|
if (!save_args->defaultName.length) return SFD_ERR_NEED_DEFAULT_NAME;
|
||||||
|
|
||||||
// save the item to a temp file, which is then (usually) later deleted by intent callback
|
// save the item to a temp file, which is then (usually) later deleted by intent callback
|
||||||
cc_string tmpDir = String_FromConst("Exported");
|
Directory_Create("Exported");
|
||||||
Directory_Create(&tmpDir);
|
|
||||||
|
|
||||||
cc_string path; char pathBuffer[FILENAME_SIZE];
|
cc_string path; char pathBuffer[FILENAME_SIZE];
|
||||||
String_InitArray(path, pathBuffer);
|
String_InitArray(path, pathBuffer);
|
||||||
String_Format3(&path, "%s/%s%c", &tmpDir, &save_args->defaultName, save_args->filters[0]);
|
String_Format2(&path, "Exported/%s%c", &save_args->defaultName, save_args->filters[0]);
|
||||||
save_args->Callback(&path);
|
save_args->Callback(&path);
|
||||||
// TODO kinda ugly, maybe a better way?
|
// TODO kinda ugly, maybe a better way?
|
||||||
cc_string file = String_UNSAFE_SubstringAt(&path, String_IndexOf(&path, '/') + 1);
|
cc_string file = String_UNSAFE_SubstringAt(&path, String_IndexOf(&path, '/') + 1);
|
||||||
|
@ -668,11 +668,10 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
|
|||||||
// UIDocumentPickerViewController - iOS 8.0
|
// UIDocumentPickerViewController - iOS 8.0
|
||||||
|
|
||||||
// save the item to a temp file, which is then (usually) later deleted by picker callbacks
|
// save the item to a temp file, which is then (usually) later deleted by picker callbacks
|
||||||
cc_string tmpDir = String_FromConst("Exported");
|
Directory_Create("Exported");
|
||||||
Directory_Create(&tmpDir);
|
|
||||||
|
|
||||||
save_path.length = 0;
|
save_path.length = 0;
|
||||||
String_Format3(&save_path, "%s/%s%c", &tmpDir, &args->defaultName, args->filters[0]);
|
String_Format2(&save_path, "Exported/%s%c", &args->defaultName, args->filters[0]);
|
||||||
args->Callback(&save_path);
|
args->Callback(&save_path);
|
||||||
|
|
||||||
NSString* str = ToNSString(&save_path);
|
NSString* str = ToNSString(&save_path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user