[Scummvm-cvs-logs] CVS: scummvm/backends/fs/ps2 ps2-fs.cpp,NONE,1.1
Robert Göffringmann
lavosspawn at users.sourceforge.net
Wed Mar 30 21:36:12 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common config-manager.cpp,1.31,1.32 scummsys.h,1.56,1.57 stdafx.h,1.25,1.26 system.cpp,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/backends/fs/ps2 ps2-fs.cpp,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/backends/fs/ps2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21872/backends/fs/ps2
Added Files:
ps2-fs.cpp
Log Message:
Playstation2 Port: initial import
--- NEW FILE: ps2-fs.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2002-2004 The ScummVM project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/backends/fs/ps2/ps2-fs.cpp,v 1.1 2005/03/31 05:35:04 lavosspawn Exp $
*/
#include "../fs.h"
#include <kernel.h>
#include <stdio.h>
#include <stdlib.h>
#include <cdvd_rpc.h>
#define MAX_LIST_ENTRIES 64
class Ps2FilesystemNode : public AbstractFilesystemNode {
protected:
String _displayName;
bool _isDirectory;
bool _isRoot;
String _path;
public:
Ps2FilesystemNode(void);
Ps2FilesystemNode(const Ps2FilesystemNode *node);
Ps2FilesystemNode(const String &path);
virtual String displayName() const { return _displayName; }
virtual bool isValid() const { return true; }
virtual bool isDirectory() const { return _isDirectory; }
virtual String path() const { return _path; }
virtual FSList listDir(ListMode) const;
virtual AbstractFilesystemNode *parent() const;
virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); }
};
AbstractFilesystemNode *FilesystemNode::getRoot(void) {
return new Ps2FilesystemNode();
}
AbstractFilesystemNode *FilesystemNode::getNodeForPath(const String &path) {
return new Ps2FilesystemNode(path);
}
Ps2FilesystemNode::Ps2FilesystemNode(void) {
_isDirectory = true;
_isRoot = true;
_displayName = "CD Root";
_path = "cdfs:";
}
Ps2FilesystemNode::Ps2FilesystemNode(const String &path) {
if (strcmp(path.c_str(), "cdfs:") == 0)
_isRoot = true;
_path = path;
const char *dsplName = NULL, *pos = path.c_str();
while (*pos)
if (*pos++ == '/')
dsplName = pos;
_displayName = String(dsplName);
_isDirectory = true;
}
Ps2FilesystemNode::Ps2FilesystemNode(const Ps2FilesystemNode *node) {
_displayName = node->_displayName;
_isDirectory = node->_isDirectory;
_path = node->_path;
_isRoot = node->_isRoot;
}
FSList Ps2FilesystemNode::listDir(ListMode mode) const {
assert(_isDirectory);
FSList myList;
struct TocEntry tocEntries[MAX_LIST_ENTRIES];
int files;
char listDir[512];
sprintf(listDir, "%s/", _path.c_str() + 5);
switch(mode) {
case kListFilesOnly:
files = CDVD_GetDir(listDir, NULL, CDVD_GET_FILES_ONLY, tocEntries, MAX_LIST_ENTRIES, NULL);
break;
case kListDirectoriesOnly:
files = CDVD_GetDir(listDir, NULL, CDVD_GET_DIRS_ONLY, tocEntries, MAX_LIST_ENTRIES, NULL);
break;
default:
files = CDVD_GetDir(listDir, NULL, CDVD_GET_FILES_AND_DIRS, tocEntries, MAX_LIST_ENTRIES, NULL);
break;
}
Ps2FilesystemNode dirEntry;
for (int fCnt = 0; fCnt < files; fCnt++) {
if (tocEntries[fCnt].filename[0] != '.') { // skip .. directory
dirEntry._isDirectory = (bool)(tocEntries[fCnt].fileProperties & 2);
dirEntry._isRoot = false;
dirEntry._path = _path;
dirEntry._path += "/";
dirEntry._path += tocEntries[fCnt].filename;
dirEntry._displayName = tocEntries[fCnt].filename;
myList.push_back(wrap(new Ps2FilesystemNode(&dirEntry)));
}
}
return myList;
}
AbstractFilesystemNode *Ps2FilesystemNode::parent() const {
if (_isRoot)
return new Ps2FilesystemNode(this);
Ps2FilesystemNode *p = new Ps2FilesystemNode();
const char *slash = NULL;
const char *cnt = _path.c_str();
while (*cnt) {
if (*cnt == '/')
slash = cnt;
cnt++;
}
p->_path = String(_path.c_str(), slash - _path.c_str());
p->_isDirectory = true;
p->_displayName = slash + 1;
return p;
}
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common config-manager.cpp,1.31,1.32 scummsys.h,1.56,1.57 stdafx.h,1.25,1.26 system.cpp,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/backends/fs/ps2 ps2-fs.cpp,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list