This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 358 for ps


Ignore:
Timestamp:
06/02/04 18:12:13 (21 years ago)
Author:
janwas
Message:

yet more tree_lookup fixes for bug pointed out by simon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/lib/res/vfs.cpp

    r354 r358  
    351351    Dir* cur_dir = &vfs_root;
    352352    const char* cur_component = buf;
    353     bool is_last_component = false;
    354353
    355354    // subdirectory traverse logic
     
    374373        if(slash)
    375374            *slash = 0;
    376         // allow root dir ("") and trailing '/' if looking up a dir
     375
     376        // early outs:
     377        // .. last component and it's a filename
     378        if(slash == 0 && loc != 0)
     379            break;
     380        // .. root dir ("") or trailing '/' in dir name
    377381        if(*cur_component == '\0' && loc == 0)
    378382            break;
    379         is_last_component = (slash == 0);
    380383
    381384        // create <cur_component> subdir (no-op if it already exists)
     
    384387
    385388        // switch to <cur_component>
    386         Dir* subdir = cur_dir->find_subdir(cur_component);
    387         if(!subdir)
    388         {
    389             // this last component is a filename.
    390             if(is_last_component && loc != 0)
    391                 break;
    392             // otherwise, we had an (invalid) subdir name - fail.
     389        cur_dir = cur_dir->find_subdir(cur_component);
     390        if(!cur_dir)
    393391            return -ENOENT;
    394         }
    395         cur_dir = subdir; // don't assign if invalid - need cur_dir below.
    396392
    397393        // next component
    398         if(is_last_component)
     394        if(!slash)  // done, no more components left
    399395            break;
    400396        cur_component = slash+1;
Note: See TracChangeset for help on using the changeset viewer.