Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

AbstractFSNode * Ps2FilesystemNode::getChild ( const Common::String name  )  const [virtual]

Returns the child node with the given name. When called on a non-directory node, it should handle this gracefully by returning 0. When called with a name not matching any of the files/dirs contained in this directory, a valid node should be returned, which returns 'false' upon calling the exists() method. The idea is that this node can then still can be used to create a new file via the createWriteStream() method.

Example: Calling getChild() for a node with path "/foo/bar" using name="file.txt", would produce a new node with "/foo/bar/file.txt" as path.

Note:
Handling calls on non-dir nodes gracefully makes it possible to switch to a lazy type detection scheme in the future.
Parameters:
name String containing the name of the child to create a new node.

Implements AbstractFSNode.

Definition at line 344 of file ps2-fs.cpp.

References Common::String::c_str(), Common::String::lastChar(), and Ps2FilesystemNode().

                                                                       {

      printf("getChild : %s\n", n.c_str());

      if (!_isDirectory)
            return NULL;

      if (_isRoot) {
            if (n.lastChar() == ':')
                  return new Ps2FilesystemNode(n);
            else
                  return NULL;
      }

      return new Ps2FilesystemNode(_path+n, 1);

/*
      int fd;

      if (_path == "pfs0:")
            fd = fio.dopen("pfs0:/");
      else
            fd = fio.dopen(_path.c_str());

      if (fd >= 0) {
            iox_dirent_t dirent;

            while (fio.dread(fd, &dirent) > 0) {
                  if (strcmp(n.c_str(), dirent.name) == 0) {
                        Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();

                        dirEntry->_isHere = true;
                        dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
                        dirEntry->_isRoot = false;

                        dirEntry->_path = _path;
                        dirEntry->_path += dirent.name;
                        if (dirEntry->_isDirectory && dirEntry->_path.lastChar() != '/')
                              dirEntry->_path += '/';
                        dirEntry->_displayName = dirent.name;

                        dirEntry->_verified = true;

                        fio.dclose(fd);
                        return dirEntry;
                  }
            }
            fio.dclose(fd);
      }

      return NULL;
*/
}


Generated by  Doxygen 1.6.0   Back to index