Ticket #8729: 1_rename_filename.patch
File 1_rename_filename.patch, 4.7 KB (added by , 17 years ago) |
---|
-
common/fs.h
225 225 * 226 226 * @param results List to put the matches in. 227 227 * @param fslist List of directories to search within. 228 * @param filename Name of the fileto look for.228 * @param pattern Pattern of the files to look for. 229 229 * @param hidden Whether to search hidden files or not. 230 230 * @param exhaustive Whether to continue searching after one match has been found. 231 231 * 232 232 * @return true if matches could be found, false otherwise. 233 233 */ 234 virtual bool lookupFile(FSList &results, FSList &fslist, Common::String & filename, bool hidden, bool exhaustive) const;234 virtual bool lookupFile(FSList &results, FSList &fslist, Common::String &pattern, bool hidden, bool exhaustive) const; 235 235 236 236 /** 237 237 * Searches recursively for a filename inside the given directory. … … 240 240 * are scanned before going into subdirectories. 241 241 * 242 242 * @param results List to put the matches in. 243 * @param FilesystemNodeDirectory to search within.244 * @param filename Name of the fileto look for.243 * @param dir Directory to search within. 244 * @param pattern Pattern of the files to look for. 245 245 * @param hidden Whether to search hidden files or not. 246 246 * @param exhaustive Whether to continue searching after one match has been found. 247 247 * 248 248 * @return true if matches could be found, false otherwise. 249 249 */ 250 virtual bool lookupFile(FSList &results, FilesystemNode &dir, Common::String & filename, bool hidden, bool exhaustive) const;250 virtual bool lookupFile(FSList &results, FilesystemNode &dir, Common::String &pattern, bool hidden, bool exhaustive) const; 251 251 252 252 protected: 253 253 /** … … 263 263 * are scanned before going into subdirectories. 264 264 * 265 265 * @param results List to put the matches in. 266 * @param FilesystemNodeDirectory to search within.267 * @param filename Name of the fileto look for.266 * @param dir Directory to search within. 267 * @param pattern Pattern of the files to look for. 268 268 * @param hidden Whether to search hidden files or not. 269 269 * @param exhaustive Whether to continue searching after one match has been found. 270 270 * 271 271 * @return The number of matches found. 272 272 */ 273 int lookupFileRec(FSList &results, FilesystemNode &dir, Common::String & filename, bool hidden, bool exhaustive) const;273 int lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &pattern, bool hidden, bool exhaustive) const; 274 274 }; 275 275 276 276 //} // End of namespace Common -
common/fs.cpp
171 171 return _realNode->isWritable(); 172 172 } 173 173 174 bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const 175 { 174 bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &pattern, bool hidden, bool exhaustive) const { 176 175 int matches = 0; 177 176 178 177 for (FSList::iterator entry = fslist.begin(); entry != fslist.end(); ++entry) { 179 178 if (entry->isDirectory()) { 180 matches += lookupFileRec(results, *entry, filename, hidden, exhaustive);179 matches += lookupFileRec(results, *entry, pattern, hidden, exhaustive); 181 180 } 182 181 } 183 182 184 183 return ((matches > 0) ? true : false); 185 184 } 186 185 187 bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const 188 { 186 bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &pattern, bool hidden, bool exhaustive) const { 189 187 int matches; 190 188 191 189 if (!dir.isDirectory()) 192 190 return false; 193 191 194 matches = lookupFileRec(results, dir, filename, hidden, exhaustive);192 matches = lookupFileRec(results, dir, pattern, hidden, exhaustive); 195 193 196 194 return ((matches > 0) ? true : false); 197 195 } 198 196 199 int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const 200 { 197 int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &pattern, bool hidden, bool exhaustive) const { 201 198 FSList entries; 202 199 FSList children; 203 200 int matches = 0; … … 208 205 if (entry->isDirectory()) { 209 206 children.push_back(*entry); 210 207 } else { 211 if (Common::matchString(entry->getName().c_str(), filename.c_str())) {208 if (Common::matchString(entry->getName().c_str(), pattern.c_str())) { 212 209 results.push_back(*entry); 213 210 matches++; 214 211 … … 220 217 221 218 //Depth search (entries in lower levels) 222 219 for (FSList::iterator child = children.begin(); child != children.end(); ++child) { 223 matches += lookupFileRec(results, *child, filename, hidden, exhaustive);220 matches += lookupFileRec(results, *child, pattern, hidden, exhaustive); 224 221 } 225 222 226 223 return matches;