55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
#pragma once
|
|
#include "std.h"
|
|
#include "errors.h"
|
|
#include "string/str.h"
|
|
|
|
#if !defined(KFS_USE_WINDOWS_H)
|
|
#if defined(_WIN64) || defined(_WIN32)
|
|
#define KFS_USE_WINDOWS_H 1
|
|
#else
|
|
#define KFS_USE_WINDOWS_H 0
|
|
#endif
|
|
#endif
|
|
|
|
#if KFS_USE_WINDOWS_H
|
|
#define path_sep '\\'
|
|
#define path_seps "\\"
|
|
#define path_notsep '/'
|
|
#define path_notseps "/"
|
|
#else
|
|
#define path_sep '/'
|
|
#define path_seps "/"
|
|
#define path_notsep '\\'
|
|
#define path_notseps "\\"
|
|
#endif
|
|
|
|
/// @brief removes part of path after path_sep
|
|
/// @return str with data = path.data
|
|
str path_dirname(str path);
|
|
|
|
/// @brief removes part of path before path_sep
|
|
/// @return str with data = path.data
|
|
str path_basename(str path, bool remove_ext);
|
|
|
|
|
|
/// open a file for reading
|
|
#define FO_Read "rb"
|
|
/// (re)create a file for writing
|
|
#define FO_Write "wb"
|
|
/// opens file for writing additional data to the end / creates new file
|
|
#define FO_Append "ab"
|
|
/// (re)creates file for reading/writing
|
|
#define FO_ReadWrite "w+b"
|
|
/// opens file for readng/writing additional data to the end / creates new file
|
|
#define FO_ReadAppend "a+b"
|
|
|
|
Result(FILE*) file_open(cstr file_name, cstr fopen_mode);
|
|
|
|
bool file_exists(cstr path);
|
|
|
|
|
|
|
|
bool dir_exists(cstr path);
|
|
|
|
Result(void) dir_create(cstr path);
|