From 9c0a8715457403d136afef4d9e11e8d0e2d2ae37 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 14 Dec 2018 14:23:23 -0800 Subject: [PATCH] Breaking down file change listening nonsense --- platform_all/4ed_system_shared.cpp | 45 --------------------------- platform_linux/linux_4ed.cpp | 49 ++++++++++++++++++++++++++++++ platform_mac/mac_4ed.cpp | 48 +++++++++++++++++++++++++++++ platform_win32/win32_4ed.cpp | 49 ++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 45 deletions(-) diff --git a/platform_all/4ed_system_shared.cpp b/platform_all/4ed_system_shared.cpp index 41b67d1d..c7ee9873 100644 --- a/platform_all/4ed_system_shared.cpp +++ b/platform_all/4ed_system_shared.cpp @@ -77,51 +77,6 @@ handle_track_out_of_memory(i32 val){ return(result); } -internal -Sys_Add_Listener_Sig(system_add_listener){ - b32 result = false; - for (;;){ - i32 track_result = add_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); - if (handle_track_out_of_memory(track_result)){ - if (track_result == FileTrack_Good){ - result = true; - } - break; - } - } - return(result); -} - -internal -Sys_Remove_Listener_Sig(system_remove_listener){ - b32 result = false; - i32 track_result = remove_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); - if (track_result == FileTrack_Good){ - result = true; - } - return(result); -} - -internal -Sys_Get_File_Change_Sig(system_get_file_change){ - b32 result = false; - - i32 size = 0; - i32 get_result = get_change_event(&shared_vars.track, &shared_vars.scratch, (u8*)buffer, max, &size); - - *required_size = size; - *mem_too_small = false; - if (get_result == FileTrack_Good){ - result = true; - } - else if (get_result == FileTrack_MemoryTooSmall){ - *mem_too_small = true; - result = true; - } - - return(result); -} - // // General shared pieces // diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index cbc9a7b4..f4e0c9b4 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -329,6 +329,55 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){ #include "4ed_system_shared.cpp" +// +// File Change Listener +// + +internal +Sys_Add_Listener_Sig(system_add_listener){ + b32 result = false; + for (;;){ + i32 track_result = add_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); + if (handle_track_out_of_memory(track_result)){ + if (track_result == FileTrack_Good){ + result = true; + } + break; + } + } + return(result); +} + +internal +Sys_Remove_Listener_Sig(system_remove_listener){ + b32 result = false; + i32 track_result = remove_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); + if (track_result == FileTrack_Good){ + result = true; + } + return(result); +} + +internal +Sys_Get_File_Change_Sig(system_get_file_change){ + b32 result = false; + + i32 size = 0; + i32 get_result = get_change_event(&shared_vars.track, &shared_vars.scratch, (u8*)buffer, max, &size); + + *required_size = size; + *mem_too_small = false; + if (get_result == FileTrack_Good){ + result = true; + } + else if (get_result == FileTrack_MemoryTooSmall){ + *mem_too_small = true; + result = true; + } + + return(result); +} + // // Clipboard // diff --git a/platform_mac/mac_4ed.cpp b/platform_mac/mac_4ed.cpp index 78a2b471..dcf4deed 100644 --- a/platform_mac/mac_4ed.cpp +++ b/platform_mac/mac_4ed.cpp @@ -206,6 +206,54 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){ #include "4ed_system_shared.cpp" +// File Change Listeners + +internal +Sys_Add_Listener_Sig(system_add_listener){ + b32 result = false; + for (;;){ + i32 track_result = add_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); + if (handle_track_out_of_memory(track_result)){ + if (track_result == FileTrack_Good){ + result = true; + } + break; + } + } + return(result); +} + +internal +Sys_Remove_Listener_Sig(system_remove_listener){ + b32 result = false; + i32 track_result = remove_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); + if (track_result == FileTrack_Good){ + result = true; + } + return(result); +} + +internal +Sys_Get_File_Change_Sig(system_get_file_change){ + b32 result = false; + + i32 size = 0; + i32 get_result = get_change_event(&shared_vars.track, &shared_vars.scratch, (u8*)buffer, max, &size); + + *required_size = size; + *mem_too_small = false; + if (get_result == FileTrack_Good){ + result = true; + } + else if (get_result == FileTrack_MemoryTooSmall){ + *mem_too_small = true; + result = true; + } + + return(result); +} + + // // Clipboard // diff --git a/platform_win32/win32_4ed.cpp b/platform_win32/win32_4ed.cpp index c16de0d1..13e439f2 100644 --- a/platform_win32/win32_4ed.cpp +++ b/platform_win32/win32_4ed.cpp @@ -288,6 +288,55 @@ Sys_Is_Fullscreen_Sig(system_is_fullscreen){ #include "4ed_system_shared.cpp" +// +// File Change Listener +// + +internal +Sys_Add_Listener_Sig(system_add_listener){ + b32 result = false; + for (;;){ + i32 track_result = add_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); + if (handle_track_out_of_memory(track_result)){ + if (track_result == FileTrack_Good){ + result = true; + } + break; + } + } + return(result); +} + +internal +Sys_Remove_Listener_Sig(system_remove_listener){ + b32 result = false; + i32 track_result = remove_listener(&shared_vars.track, &shared_vars.scratch, (u8*)filename); + if (track_result == FileTrack_Good){ + result = true; + } + return(result); +} + +internal +Sys_Get_File_Change_Sig(system_get_file_change){ + b32 result = false; + + i32 size = 0; + i32 get_result = get_change_event(&shared_vars.track, &shared_vars.scratch, (u8*)buffer, max, &size); + + *required_size = size; + *mem_too_small = false; + if (get_result == FileTrack_Good){ + result = true; + } + else if (get_result == FileTrack_MemoryTooSmall){ + *mem_too_small = true; + result = true; + } + + return(result); +} + // // Clipboard //