Ticket #8530: amigaos4-fs.diff

File amigaos4-fs.diff, 2.3 KB (added by SF/capehill, 18 years ago)

AmigaOS 4 filesystem changes

  • backends/fs/amigaos4/amigaos4-fs.cpp

     
    114114        }
    115115
    116116        _sDisplayName = String(str + offset, len);
    117 
    118117        _pFileLock = 0;
    119118
    120         // Check whether it is a directory, and whether the file actually exists
    121 
    122119        struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
    123120        if (!fib) {
    124121                debug(6, "FileInfoBlock is NULL");
     
    126123                return;
    127124        }
    128125
     126        // Check whether the node exists and if it is a directory
    129127        BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
    130128        if (pLock) {
    131129                if (IDOS->Examine(pLock, fib) != DOSFALSE) {
    132                         if (fib->fib_EntryType > 0)
     130                        if (FIB_IS_DRAWER(fib)) {
    133131                                _bIsDirectory = true;
    134                         else
    135                                 _bIsDirectory = false;
     132                                _pFileLock = IDOS->DupLock(pLock);
     133                                _bIsValid = (_pFileLock != 0);
    136134
    137                         if (_bIsDirectory) {
    138                                 if (fib->fib_EntryType != ST_ROOT)
    139                                         _sPath += "/";
     135                                // Add a trailing slash if it is needed
     136                                const char c = _sPath.lastChar();
     137                                if (c != '/' && c != ':')
     138                                        _sPath += '/';
    140139
    141                                 _pFileLock = IDOS->DupLock(pLock);
    142                                 _bIsValid = (_pFileLock != 0);
    143140                        }
    144                         else _bIsValid = true;
     141                        else {
     142                                _bIsDirectory = false;
     143                                _bIsValid = true;
     144                        }                       
    145145                }
    146146        }
    147147
     
    184184        }
    185185
    186186        if (IDOS->Examine(pLock, fib) != DOSFALSE) {
    187                 if (fib->fib_EntryType > 0)
     187                if (FIB_IS_DRAWER(fib)) {
    188188                        _bIsDirectory = true;
    189                 else
    190                         _bIsDirectory = false;
     189                        _pFileLock = IDOS->DupLock(pLock);
     190                        _bIsValid = _pFileLock != 0;
    191191
    192                 if (_bIsDirectory) {
    193                         if (fib->fib_EntryType != ST_ROOT)
    194                                 _sPath += "/";
    195 
    196                         _pFileLock = IDOS->DupLock(pLock);
    197                         _bIsValid = (_pFileLock != 0);
     192                        const char c = _sPath.lastChar();
     193                        if (c != '/' && c != ':')
     194                                _sPath += '/';
    198195                }
    199                 else _bIsValid = true;
     196                else {
     197                        _bIsDirectory = false;
     198                        _bIsValid = true;
     199                }               
    200200        }
    201201
    202202        IDOS->FreeDosObject(DOS_FIB, fib);
     
    325325}
    326326
    327327AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &name) const {
    328         TODO
     328        assert(_bIsDirectory);
     329        String newPath(_sPath);
     330        if (_sPath.lastChar() != '/')
     331                newPath += '/';
     332        newPath += name;
     333        return new AmigaOSFilesystemNode(newPath);
    329334}
    330335
    331336FSList AmigaOSFilesystemNode::listVolumes(void) const {