mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 12:58:41 +00:00
merge
This commit is contained in:
@@ -443,6 +443,12 @@ os_copy_file_path(String8 dst, String8 src)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_move_file_path(String8 dst, String8 src)
|
||||
{
|
||||
// TODO(rjf)
|
||||
}
|
||||
|
||||
internal String8
|
||||
os_full_path_from_path(Arena *arena, String8 path)
|
||||
{
|
||||
|
||||
@@ -202,6 +202,7 @@ internal void os_abort(S32 exit_code);
|
||||
internal OS_Handle os_file_open(OS_AccessFlags flags, String8 path);
|
||||
internal void os_file_close(OS_Handle file);
|
||||
internal U64 os_file_read(OS_Handle file, Rng1U64 rng, void *out_data);
|
||||
#define os_file_read_struct(f, off, ptr) os_file_read((f), r1u64((off), (off)+sizeof(*(ptr))), (ptr))
|
||||
internal U64 os_file_write(OS_Handle file, Rng1U64 rng, void *data);
|
||||
internal B32 os_file_set_times(OS_Handle file, DateTime time);
|
||||
internal FileProperties os_properties_from_file(OS_Handle file);
|
||||
@@ -209,6 +210,7 @@ internal OS_FileID os_id_from_file(OS_Handle file);
|
||||
internal B32 os_file_reserve_size(OS_Handle file, U64 size);
|
||||
internal B32 os_delete_file_at_path(String8 path);
|
||||
internal B32 os_copy_file_path(String8 dst, String8 src);
|
||||
internal B32 os_move_file_path(String8 dst, String8 src);
|
||||
internal String8 os_full_path_from_path(Arena *arena, String8 path);
|
||||
internal B32 os_file_path_exists(String8 path);
|
||||
internal B32 os_folder_path_exists(String8 path);
|
||||
|
||||
@@ -503,6 +503,17 @@ os_copy_file_path(String8 dst, String8 src)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal B32
|
||||
os_move_file_path(String8 dst, String8 src)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
String16 dst16 = str16_from_8(scratch.arena, dst);
|
||||
String16 src16 = str16_from_8(scratch.arena, src);
|
||||
B32 result = MoveFileW((WCHAR*)src16.str, (WCHAR*)dst16.str);
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8
|
||||
os_full_path_from_path(Arena *arena, String8 path)
|
||||
{
|
||||
@@ -560,6 +571,28 @@ os_properties_from_file_path(String8 path)
|
||||
os_w32_dense_time_from_file_time(&props.modified, &find_data.ftLastWriteTime);
|
||||
props.flags = os_w32_file_property_flags_from_dwFileAttributes(find_data.dwFileAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
WCHAR buffer[512] = {0};
|
||||
DWORD length = GetLogicalDriveStringsW(sizeof(buffer), buffer);
|
||||
U64 last_slash_pos = 0;
|
||||
for(;last_slash_pos < path.size; last_slash_pos = str8_find_needle(path, last_slash_pos+1, str8_lit("/"), StringMatchFlag_SlashInsensitive));
|
||||
String8 path_trimmed = str8_prefix(path, last_slash_pos);
|
||||
for(U64 off = 0; off < (U64)length;)
|
||||
{
|
||||
String16 next_drive_string_16 = str16_cstring((U16 *)buffer+off);
|
||||
off += next_drive_string_16.size+1;
|
||||
String8 next_drive_string = str8_from_16(scratch.arena, next_drive_string_16);
|
||||
next_drive_string = str8_chop_last_slash(next_drive_string);
|
||||
if(str8_match(path_trimmed, next_drive_string, StringMatchFlag_CaseInsensitive))
|
||||
{
|
||||
props.flags |= FilePropertyFlag_IsFolder;
|
||||
break;
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
FindClose(handle);
|
||||
scratch_end(scratch);
|
||||
return props;
|
||||
|
||||
Reference in New Issue
Block a user