file.cpp

changeset 104
6e29bb0e83c5
parent 99
920d51fec412
child 109
f40b35142586
equal deleted inserted replaced
103:b0a345196435 104:6e29bb0e83c5
1 /* 1 /*
2 * LDForge: LDraw parts authoring CAD 2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri `arezey` Piippo 3 * Copyright (C) 2013 Santeri Piippo
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or 7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
34 OpenFile* findLoadedFile (str zName) { 34 OpenFile* findLoadedFile (str zName) {
35 for (OpenFile* file : g_LoadedFiles) 35 for (OpenFile* file : g_LoadedFiles)
36 if (file->zFileName == zName) 36 if (file->zFileName == zName)
37 return file; 37 return file;
38 38
39 return nullptr; 39 return null;
40 } 40 }
41 41
42 // ============================================================================= 42 // =============================================================================
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
44 // ============================================================================= 44 // =============================================================================
50 #endif // WIN32 50 #endif // WIN32
51 51
52 FILE* fp = fopen (path.chars (), "r"); 52 FILE* fp = fopen (path.chars (), "r");
53 str zFilePath; 53 str zFilePath;
54 54
55 if (fp != nullptr) 55 if (fp != null)
56 return fp; 56 return fp;
57 57
58 if (~io_ldpath.value) { 58 if (~io_ldpath.value) {
59 // Try with just the LDraw path first 59 // Try with just the LDraw path first
60 zFilePath = str::mkfmt ("%s" DIRSLASH "%s", 60 zFilePath = str::mkfmt ("%s" DIRSLASH "%s",
61 io_ldpath.value.chars(), zTruePath.chars()); 61 io_ldpath.value.chars(), zTruePath.chars());
62 printf ("try %s\n", zFilePath.chars()); 62 printf ("try %s\n", zFilePath.chars());
63 63
64 fp = fopen (zFilePath, "r"); 64 fp = fopen (zFilePath, "r");
65 if (fp != nullptr) 65 if (fp != null)
66 return fp; 66 return fp;
67 67
68 if (bSubDirectories) { 68 if (bSubDirectories) {
69 char const* saSubdirectories[] = { 69 char const* saSubdirectories[] = {
70 "parts", 70 "parts",
82 return fp; 82 return fp;
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 return nullptr; 87 return null;
88 } 88 }
89 89
90 // ============================================================================= 90 // =============================================================================
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
92 // ============================================================================= 92 // =============================================================================
98 // file names for the actual parts.. 98 // file names for the actual parts..
99 FILE* fp = openLDrawFile (-path, true); 99 FILE* fp = openLDrawFile (-path, true);
100 100
101 if (!fp) { 101 if (!fp) {
102 logf (LOG_Error, "Couldn't open %s: %s\n", path.chars (), strerror (errno)); 102 logf (LOG_Error, "Couldn't open %s: %s\n", path.chars (), strerror (errno));
103 return nullptr; 103 return null;
104 } 104 }
105 105
106 OpenFile* load = new OpenFile; 106 OpenFile* load = new OpenFile;
107 ulong numWarnings = 0; 107 ulong numWarnings = 0;
108 108

mercurial