Skip to content

Commit

Permalink
debug windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
eileencodes committed Feb 6, 2024
1 parent a736bef commit 92642f2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/util/pm_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

if (file == INVALID_HANDLE_VALUE) {
return errno;
int e = rb_w32_map_errno(GetLastError());
return e;
}

// Get the file size.
DWORD file_size = GetFileSize(file, NULL);
if (file_size == INVALID_FILE_SIZE) {
fprintf(stderr, "invalid file size\n");
CloseHandle(file);
return errno;
}
Expand All @@ -79,6 +81,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
// the source to a constant empty string and return.
if (file_size == 0) {
CloseHandle(file);
fprintf(stderr, "close handle\n");
const uint8_t source[] = "";
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
return 0;
Expand All @@ -88,6 +91,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL);
if (mapping == NULL) {
CloseHandle(file);
fprintf(stderr, "close handle, mapping is null\n");
return errno;
}

Expand All @@ -97,6 +101,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
CloseHandle(file);

if (source == NULL) {
fprintf(stderr, "source was null\n");
return errno;
}

Expand Down

0 comments on commit 92642f2

Please sign in to comment.