src/file.cpp

changeset 214
28e0b37156be
parent 213
a4113545242c
child 224
805bf9ef9529
equal deleted inserted replaced
213:a4113545242c 214:28e0b37156be
126 break; 126 break;
127 127
128 if (lastpos > 0) { 128 if (lastpos > 0) {
129 str dirname = g_curfile->m_filename.substr (0, lastpos); 129 str dirname = g_curfile->m_filename.substr (0, lastpos);
130 str partpath = fmt ("%s" DIRSLASH "%s", dirname.c (), relpath.c ()); 130 str partpath = fmt ("%s" DIRSLASH "%s", dirname.c (), relpath.c ());
131 printf ("try %s\n", partpath.c ());
131 FILE* fp = fopen (partpath, "r"); 132 FILE* fp = fopen (partpath, "r");
132 133
133 if (fp != null) 134 if (fp != null)
134 return fp; 135 return fp;
135 } 136 }
136 } 137 }
137 138
138 FILE* fp = fopen (relpath.chars (), "r"); 139 printf ("try %s\n", relpath.chars ());
140 FILE* fp = fopen (relpath, "r");
139 str fullPath; 141 str fullPath;
140 142
141 if (fp != null) 143 if (fp != null)
142 return fp; 144 return fp;
143 145
144 if (~io_ldpath.value) { 146 if (~io_ldpath.value) {
145 // Try with just the LDraw path first 147 // Try with just the LDraw path first
146 fullPath = fmt ("%s" DIRSLASH "%s", io_ldpath.value.chars(), relpath.chars()); 148 fullPath = fmt ("%s" DIRSLASH "%s", io_ldpath.value.chars(), relpath.chars());
149 printf ("try %s\n", fullPath.chars ());
147 150
148 fp = fopen (fullPath, "r"); 151 fp = fopen (fullPath, "r");
149 if (fp != null) 152 if (fp != null)
150 return fp; 153 return fp;
151 154
152 if (subdirs) { 155 if (subdirs) {
153 char const* saSubdirectories[] = { 156 for (auto subdir : initlist<const char*> ({"parts", "p"})) {
154 "parts",
155 "p",
156 };
157
158 for (char const* sSubdir : saSubdirectories) {
159 fullPath = fmt ("%s" DIRSLASH "%s" DIRSLASH "%s", 157 fullPath = fmt ("%s" DIRSLASH "%s" DIRSLASH "%s",
160 io_ldpath.value.chars(), sSubdir, relpath.chars()); 158 io_ldpath.value.chars(), subdir, relpath.chars());
161 159
160 printf ("try %s\n", fullPath.chars ());
162 fp = fopen (fullPath.chars (), "r"); 161 fp = fopen (fullPath.chars (), "r");
163 162
164 if (fp) 163 if (fp)
165 return fp; 164 return fp;
166 } 165 }

mercurial