List files and fix scrolling

This commit is contained in:
Krzosa Karol
2024-07-24 14:16:58 +02:00
parent 93e0104c1e
commit cb4f380313
6 changed files with 45 additions and 3 deletions

View File

@@ -741,6 +741,7 @@ UTF8Iter IterateUTF8Ex(char *data, int64_t len);
UTF8Iter IterateUTF8(char *data);
UTF8Iter IterateUTF8(String string);
bool IsAlphabetic(char a);
#define FmtString(string) (int)(string).len, (string).data
bool AreEqual(String a, String b, unsigned ignore_case = false);
int64_t CreateWidecharFromChar(wchar_t *buffer, int64_t buffer_size, char *in, int64_t inlen);

View File

@@ -31,6 +31,8 @@ String GetExeDir(Allocator allocator);
bool FileExists(String path);
bool IsDir(String path);
bool IsFile(String path);
String GetWorkingDir(Allocator arena);
bool IsAbsolute(String path);
struct Process {
bool is_valid;

View File

@@ -299,3 +299,21 @@ bool IsFile(String path) {
bool is_file = (dwAttrib & FILE_ATTRIBUTE_DIRECTORY) == 0;
return dwAttrib != INVALID_FILE_ATTRIBUTES && is_file;
}
String GetWorkingDir(Allocator arena) {
wchar_t wbuffer[1024];
DWORD wsize = GetCurrentDirectoryW(Lengthof(wbuffer), wbuffer);
Assert(wsize != 0);
Assert(wsize < 1022);
wbuffer[wsize++] = '/';
wbuffer[wsize] = 0;
String path = ToString(arena, wbuffer, wsize);
NormalizePathInPlace(path);
return path;
}
bool IsAbsolute(String path) {
bool result = path.len > 3 && IsAlphabetic(path.data[0]) && path.data[1] == ':' && path.data[2] == '/';
return result;
}