1 | 1102: FILE *ProjectFile = fopen(ProjectFileName, "r"); |
1 2 3 4 5 | D:\work\Tests\handmade_hero>icacls handmade_main.prj
handmade_main.prj BUILTIN\Administrators:(I)(F)
NT AUTHORITY\SYSTEM:(I)(F)
NT AUTHORITY\Authenticated Users:(I)(M)
BUILTIN\Users:(I)(RX)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | internal void OpenProject(Application_Links *app, char *ProjectFileName) { int TotalOpenAttempts = 0; char *Path = "D:/work/Tests/handmade_hero/handmade_main.prj"; // ProjectFileName = "D:/work/local/tests/4coder/code/handmade_main.prj" FILE *ProjectFile = fopen(Path, "r"); FILE *ProjectFile2 = fopen(ProjectFileName, "r"); if (!ProjectFile) { // This works! } if (!ProjectFile2) { // This fails - ProjectFile2 is NULL. } // rest of function } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | internal void
OpenProject(Application_Links *app, Buffer_Summary *buffer)
{
int TotalOpenAttempts = 0;
if (!buffer->exists)
{
// TODO(bk): Handle when buffer fails and print an error
return;
}
Range range = {0};
range.min = 0;
// TODO(bk): This assumes there are no spaces in the path. Need to support spaces.
range.max = buffer_seek_whitespace_right(app, buffer, range.min);
String buildDir = {0};
buildDir.str = (char*)app->memory;
buildDir.size = range.max - range.min;
assert(buildDir.size < app->memory_size);
if (!buffer_read_range(app, buffer, range.min, range.max, buildDir.str))
{
// TODO(bk): it failed to read the buffer range, print an appropriate error
return;
}
memcpy(BuildDirectory, buildDir.str, buildDir.size);
size_t BuildDirSize = strlen(BuildDirectory);
if ((BuildDirSize) && (BuildDirectory[BuildDirSize - 1] == '\n'))
{
--BuildDirSize;
}
if ((BuildDirSize) && (BuildDirectory[BuildDirSize - 1] != '/'))
{
BuildDirectory[BuildDirSize++] = '/';
BuildDirectory[BuildDirSize] = 0;
}
range.min = buildDir.size + 1;
range.max = buffer_seek_whitespace_right(app, buffer, range.min);
String codeDir = {0};
codeDir.str = (char*)app->memory;
codeDir.size = range.max - range.min;
assert(codeDir.size < app->memory_size);
if (!buffer_read_range(app, buffer, range.min, range.max, codeDir.str))
{
// TODO(bk): it failed to read the buffer range, print an appropriate error
return;
}
// TODO(bk): Looks like Casey wants to loop through the file and get each path and get all the files within each folder.
char SourceFileDirectoryName[4096];
char FileDirectoryName[4096];
// TODO(bk): Most likely do not need to do this and can use codeDir
memcpy(SourceFileDirectoryName, codeDir.str, codeDir.size);
// NOTE(allen|a3.4.4): Here we get the list of files in this directory.
// Notice that we free_file_list at the end.
String dir = make_string(FileDirectoryName, 0, sizeof(FileDirectoryName));
append(&dir, SourceFileDirectoryName);
if(dir.size && dir.str[dir.size-1] == '\n')
{
--dir.size;
}
if(dir.size && dir.str[dir.size-1] != '/')
{
dir.str[dir.size++] = '/';
}
File_List list = get_file_list(app, dir.str, dir.size);
int dir_size = dir.size;
for (int i = 0; i < list.count; ++i)
{
File_Info *info = list.infos + i;
if (!info->folder)
{
String filename = make_string(info->filename, info->filename_len);
String extension = file_extension(filename);
if (IsCode(extension))
{
// NOTE(allen): There's no way in the 4coder API to use relative
// paths at the moment, so everything should be full paths. Which is
// managable. Here simply set the dir string size back to where it
// was originally, so that new appends overwrite old ones.
dir.size = dir_size;
append(&dir, info->filename);
open_file(app, 0, dir.str, dir.size, true, true);
++TotalOpenAttempts;
}
}
}
free_file_list(app, list);
}
|
1 2 | memcpy(BuildDirectory, buildDir.str, buildDir.size); size_t BuildDirSize = strlen(BuildDirectory); |
1 2 | size_t BuildDirSize = buildDir.size; BuildDirectory[BuildDirSize] = 0; |
1 | codeDir.str = (char*)app->memory; |
1 2 | // TODO(bk): This assumes there are no spaces in the path. Need to support spaces. range.max = buffer_seek_whitespace_right(app, buffer, range.min); |