WIP Windows impl.
This commit is contained in:
parent
58269d751c
commit
3f74beefdc
1 changed files with 42 additions and 0 deletions
42
src/parser.c
42
src/parser.c
|
@ -31,6 +31,10 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#elif SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_WINDOWS
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <fileapi.h>
|
||||||
|
#include <winnt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "data_structures/hash_map.h"
|
#include "data_structures/hash_map.h"
|
||||||
|
@ -61,7 +65,11 @@ unsigned int simple_archiver_parser_internal_filename_idx(
|
||||||
} else if ((flags & 3) == 1) {
|
} else if ((flags & 3) == 1) {
|
||||||
if (filename[idx] == 0) {
|
if (filename[idx] == 0) {
|
||||||
return known_good_idx;
|
return known_good_idx;
|
||||||
|
#if SIMPLE_ARCHIVER_PLATFORM != SIMPLE_ARCHIVER_PLATFORM_WINDOWS
|
||||||
} else if (filename[idx] == '/') {
|
} else if (filename[idx] == '/') {
|
||||||
|
#else
|
||||||
|
} else if (filename[idx] == '\\') {
|
||||||
|
#endif
|
||||||
flags |= 2;
|
flags |= 2;
|
||||||
} else {
|
} else {
|
||||||
return idx - 1;
|
return idx - 1;
|
||||||
|
@ -69,7 +77,11 @@ unsigned int simple_archiver_parser_internal_filename_idx(
|
||||||
} else if ((flags & 3) == 3) {
|
} else if ((flags & 3) == 3) {
|
||||||
if (filename[idx] == 0) {
|
if (filename[idx] == 0) {
|
||||||
return known_good_idx;
|
return known_good_idx;
|
||||||
|
#if SIMPLE_ARCHIVER_PLATFORM != SIMPLE_ARCHIVER_PLATFORM_WINDOWS
|
||||||
} else if (filename[idx] == '/') {
|
} else if (filename[idx] == '/') {
|
||||||
|
#else
|
||||||
|
} else if (filename[idx] == '\\') {
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
} else if (filename[idx] == '.') {
|
} else if (filename[idx] == '.') {
|
||||||
flags &= 0xFFFFFFFC;
|
flags &= 0xFFFFFFFC;
|
||||||
|
@ -103,6 +115,34 @@ void simple_archiver_parser_internal_remove_end_slash(char *filename) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *simple_archiver_internal_forward_to_backward_slash(const char *string) {
|
||||||
|
unsigned int len = strlen(string) + 1;
|
||||||
|
char *backward_slash_string = malloc(len);
|
||||||
|
strncpy(backward_slash_string, string, len);
|
||||||
|
|
||||||
|
for (unsigned int idx = 0; idx < len; ++idx) {
|
||||||
|
if (backward_slash_string[idx] == '/') {
|
||||||
|
backward_slash_string[idx] = '\\';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return backward_slash_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *simple_archiver_internal_backward_to_forward_slash(const char *string) {
|
||||||
|
unsigned int len = strlen(string) + 1;
|
||||||
|
char *forward_slash_string = malloc(len);
|
||||||
|
strncpy(forward_slash_string, string, len);
|
||||||
|
|
||||||
|
for (unsigned int idx = 0; idx < len; ++idx) {
|
||||||
|
if (forward_slash_string[idx] == '\\') {
|
||||||
|
forward_slash_string[idx] = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return forward_slash_string;
|
||||||
|
}
|
||||||
|
|
||||||
void simple_archiver_internal_free_file_info_fn(void *data) {
|
void simple_archiver_internal_free_file_info_fn(void *data) {
|
||||||
SDArchiverFileInfo *file_info = data;
|
SDArchiverFileInfo *file_info = data;
|
||||||
if (file_info) {
|
if (file_info) {
|
||||||
|
@ -418,6 +458,8 @@ SDArchiverLinkedList *simple_archiver_parsed_to_filenames(
|
||||||
// Unhandled type. TODO handle this.
|
// Unhandled type. TODO handle this.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_WINDOWS
|
||||||
|
/* DWORD file_stats = GetFileAttributesA(*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Remove leading "./" entries from files_list.
|
// Remove leading "./" entries from files_list.
|
||||||
|
|
Loading…
Reference in a new issue