mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-11-26 15:52:23 -08:00
rebase fixes
This commit is contained in:
1 parent
1883649e18
commit
03180247c9
3 files changed
+158
-144
No files matched your search
+17
-3
@@ -111,10 +111,14 @@ lnk_file_open_with_rename_permissions(String8 path)
|
||||
internal B32
|
||||
lnk_file_set_delete_on_close(File handle, B32 delete_file)
|
||||
{
|
||||
B32 is_set = 0;
|
||||
#if OS_WINDOWS
|
||||
FILE_DISPOSITION_INFO file_disposition = {0};
|
||||
file_disposition.DeleteFile = (BOOL)delete_file;
|
||||
B32 is_set = SetFileInformationByHandle((HANDLE)handle.u64[0], FileDispositionInfo, &file_disposition, sizeof(file_disposition));
|
||||
is_set = SetFileInformationByHandle((HANDLE)handle.u64[0], FileDispositionInfo, &file_disposition, sizeof(file_disposition));
|
||||
#elif OS_LINUX
|
||||
// no equivalent
|
||||
is_set = 1;
|
||||
#else
|
||||
# error "TODO: file rename"
|
||||
#endif
|
||||
@@ -125,6 +129,7 @@ internal B32
|
||||
lnk_file_rename(File handle, String8 new_name)
|
||||
{
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
B32 is_renamed = 0;
|
||||
#if OS_WINDOWS
|
||||
String16 new_name16 = str16_from_8(scratch.arena, new_name);
|
||||
|
||||
@@ -137,9 +142,18 @@ lnk_file_rename(File handle, String8 new_name)
|
||||
rename_info->FileNameLength = new_name16.size * sizeof(new_name16.str[0]);
|
||||
MemoryCopy(rename_info->FileName, new_name16.str, new_name16.size * sizeof(new_name16.str[0]));
|
||||
|
||||
B32 is_renamed = SetFileInformationByHandle((HANDLE)handle.u64[0], FileRenameInfo, buffer, buffer_size);
|
||||
is_renamed = SetFileInformationByHandle((HANDLE)handle.u64[0], FileRenameInfo, buffer, buffer_size);
|
||||
#else
|
||||
#error "TODO: file rename"
|
||||
char fd_proc_path[128];
|
||||
raddbg_snprintf(fd_proc_path, sizeof(fd_proc_path), "/proc/self/fd/%d", (int)handle.u64[0]);
|
||||
|
||||
U64 path_max = 4096;
|
||||
char *path = push_array(scratch.arena, char, path_max);
|
||||
ssize_t path_size = readlink(fd_proc_path, path, path_max);
|
||||
|
||||
if (path_size > 0) {
|
||||
is_renamed = rename(path, (char *)push_cstr(scratch.arena, new_name).str) == 0;
|
||||
}
|
||||
#endif
|
||||
scratch_end(scratch);
|
||||
return is_renamed;
|
||||
|
||||
Reference in new issue
Block a user