Sha256: 7a9164a715e6a5b89a04dcdaedc12f6be304d4a141b3e1662444218ac419cd16
Contents?: true
Size: 1.55 KB
Versions: 3
Compression:
Stored size: 1.55 KB
Contents
#include "wdm.h" #include "memory.h" #include "utils.h" // --------------------------------------------------------- // Paths functions // --------------------------------------------------------- LPWSTR wdm_utils_convert_back_to_forward_slashes(LPWSTR path, DWORD path_len) { UINT i; for(i = 0; i < (path_len - 1); ++i) { // path_len-1 because we don't need to check the NULL-char! if ( path[i] == L'\\' ) path[i] = L'/'; } return path; } LPWSTR wdm_utils_full_pathname(const LPWSTR path) { WCHAR maxed_path[WDM_MAX_WCHAR_LONG_PATH]; LPWSTR full_path; size_t full_path_len; BOOL is_directory; if ( GetFullPathNameW(path, WDM_MAX_WCHAR_LONG_PATH, maxed_path, NULL) == 0 ) { return 0; } is_directory = wdm_utils_unicode_is_directory(maxed_path); full_path_len = wcslen(maxed_path); full_path = WDM_ALLOC_N(WCHAR, full_path_len + (is_directory ? 2 : 1)); // When it's a directory, add extra 1 for the (\) at the end wcscpy(full_path, maxed_path); if ( is_directory ) wcscat(full_path, L"\\"); return full_path; } BOOL wdm_utils_unicode_is_directory(const LPWSTR path) { WCHAR unicode_path[WDM_MAX_WCHAR_LONG_PATH]; wcscpy(unicode_path, L"\\\\?\\"); wcscat(unicode_path, path); return wdm_utils_is_directory(unicode_path); } BOOL wdm_utils_is_directory(const LPWSTR path) { DWORD dwAttrib = GetFileAttributesW(path); return (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wdm-0.0.2-x86-mingw32 | ext/wdm/utils.c |
wdm-0.0.2-mingw32 | ext/wdm/utils.c |
wdm-0.0.1 | ext/wdm/utils.c |