Ticket #8729: 1_rename_filename.patch

File 1_rename_filename.patch, 4.7 KB (added by jvprat, 17 years ago)
  • common/fs.h

     
    225225         *
    226226         * @param results List to put the matches in.
    227227         * @param fslist List of directories to search within.
    228          * @param filename Name of the file to look for.
     228         * @param pattern Pattern of the files to look for.
    229229         * @param hidden Whether to search hidden files or not.
    230230         * @param exhaustive Whether to continue searching after one match has been found.
    231231         *
    232232         * @return true if matches could be found, false otherwise.
    233233         */
    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;
    235235       
    236236        /**
    237237         * Searches recursively for a filename inside the given directory.
     
    240240         * are scanned before going into subdirectories.
    241241         *
    242242         * @param results List to put the matches in.
    243          * @param FilesystemNode Directory to search within.
    244          * @param filename Name of the file to look for.
     243         * @param dir Directory to search within.
     244         * @param pattern Pattern of the files to look for.
    245245         * @param hidden Whether to search hidden files or not.
    246246         * @param exhaustive Whether to continue searching after one match has been found.
    247247         *
    248248         * @return true if matches could be found, false otherwise.
    249249         */
    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;
    251251
    252252protected:
    253253        /**
     
    263263         * are scanned before going into subdirectories.
    264264         *
    265265         * @param results List to put the matches in.
    266          * @param FilesystemNode Directory to search within.
    267          * @param filename Name of the file to look for.
     266         * @param dir Directory to search within.
     267         * @param pattern Pattern of the files to look for.
    268268         * @param hidden Whether to search hidden files or not.
    269269         * @param exhaustive Whether to continue searching after one match has been found.
    270270         *
    271271         * @return The number of matches found.
    272272         */
    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;
    274274};
    275275
    276276//} // End of namespace Common
  • common/fs.cpp

     
    171171        return _realNode->isWritable();
    172172}
    173173
    174 bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const
    175 {
     174bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &pattern, bool hidden, bool exhaustive) const {
    176175        int matches = 0;
    177176
    178177        for (FSList::iterator entry = fslist.begin(); entry != fslist.end(); ++entry) {
    179178                if (entry->isDirectory()) {
    180                         matches += lookupFileRec(results, *entry, filename, hidden, exhaustive);
     179                        matches += lookupFileRec(results, *entry, pattern, hidden, exhaustive);
    181180                }
    182181        }
    183182
    184183        return ((matches > 0) ? true : false);
    185184}
    186185
    187 bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
    188 {
     186bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &pattern, bool hidden, bool exhaustive) const {
    189187        int matches;
    190188
    191189        if (!dir.isDirectory())
    192190                return false;
    193191
    194         matches = lookupFileRec(results, dir, filename, hidden, exhaustive);
     192        matches = lookupFileRec(results, dir, pattern, hidden, exhaustive);
    195193
    196194        return ((matches > 0) ? true : false);
    197195}
    198196
    199 int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
    200 {
     197int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &pattern, bool hidden, bool exhaustive) const {
    201198        FSList entries;
    202199        FSList children;
    203200        int matches = 0;
     
    208205                if (entry->isDirectory()) {
    209206                        children.push_back(*entry);
    210207                } else {
    211                         if (Common::matchString(entry->getName().c_str(), filename.c_str())) {
     208                        if (Common::matchString(entry->getName().c_str(), pattern.c_str())) {
    212209                                results.push_back(*entry);
    213210                                matches++;
    214211
     
    220217
    221218        //Depth search (entries in lower levels)
    222219        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);
    224221        }
    225222
    226223        return matches;