2023-05-26 14:03:23 +00:00
|
|
|
/************************************************************//**
|
|
|
|
*
|
|
|
|
* @file: win32_path.c
|
|
|
|
* @author: Martin Fouilleul
|
|
|
|
* @date: 24/05/2023
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
2023-06-16 13:30:48 +00:00
|
|
|
#include<shlwapi.h> // PathIsRelative()
|
2023-05-26 14:03:23 +00:00
|
|
|
|
2023-06-16 13:30:48 +00:00
|
|
|
#include"win32_string_helpers.h"
|
2023-05-26 14:03:23 +00:00
|
|
|
#include"platform_path.c"
|
|
|
|
|
2023-06-16 13:30:48 +00:00
|
|
|
bool path_is_absolute(str8 path)
|
|
|
|
{
|
|
|
|
mem_arena_scope scratch = mem_scratch_begin();
|
|
|
|
str16 pathW = win32_utf8_to_wide_null_terminated(scratch.arena, path);
|
|
|
|
bool result = !PathIsRelativeW(pathW.ptr);
|
|
|
|
|
|
|
|
mem_scratch_end(scratch);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2023-05-26 14:03:23 +00:00
|
|
|
str8 path_executable(mem_arena* arena)
|
|
|
|
{
|
2023-06-26 14:06:26 +00:00
|
|
|
///////////////////////////////////////////////////////////////////
|
2023-05-26 14:03:23 +00:00
|
|
|
//TODO use wide chars
|
2023-06-26 14:06:26 +00:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
char* buffer = mem_arena_alloc_array(arena, char, MAX_PATH+2);
|
2023-05-26 14:03:23 +00:00
|
|
|
int size = GetModuleFileName(NULL, buffer, MAX_PATH+1);
|
|
|
|
//TODO: check for errors...
|
|
|
|
for(int i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
if(buffer[i] == '\\')
|
|
|
|
{
|
|
|
|
buffer[i] = '/';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(str8_from_buffer(size, buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
str8 path_canonical(mem_arena* arena, str8 path); //TODO
|