Removed the isValid operation from the FilesystemNode class in favor of the much richer combinations possible with the new operations (exists, isReadable and isWritable).
The work on the Common::File class is far from complete. Only the necessary was updated. svn-id: r27473
This commit is contained in:
parent
b405220ff2
commit
f7ea7e666d
7 changed files with 17 additions and 25 deletions
|
@ -121,11 +121,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool isReadable() const = 0;
|
virtual bool isReadable() const = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether this path is valid or not for usage.
|
|
||||||
*/
|
|
||||||
virtual bool isValid() const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether this path can be written to or not.
|
* Indicates whether this path can be written to or not.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -68,7 +68,6 @@ public:
|
||||||
virtual String getPath() const { return _path; }
|
virtual String getPath() const { return _path; }
|
||||||
virtual bool isDirectory() const { return _isDirectory; }
|
virtual bool isDirectory() const { return _isDirectory; }
|
||||||
virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
||||||
virtual bool isValid() const { return _isValid; }
|
|
||||||
virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
|
virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
|
||||||
|
|
||||||
virtual AbstractFilesystemNode *getChild(const String &n) const;
|
virtual AbstractFilesystemNode *getChild(const String &n) const;
|
||||||
|
|
|
@ -364,13 +364,19 @@ bool File::open(const String &filename, AccessMode mode) {
|
||||||
bool File::open(const FilesystemNode &node, AccessMode mode) {
|
bool File::open(const FilesystemNode &node, AccessMode mode) {
|
||||||
assert(mode == kFileReadMode || mode == kFileWriteMode);
|
assert(mode == kFileReadMode || mode == kFileWriteMode);
|
||||||
|
|
||||||
if (!node.isValid()) {
|
if (!node.exists()) {
|
||||||
warning("File::open: Trying to open an invalid FilesystemNode object");
|
warning("File::open: Trying to open a FilesystemNode which does not exist");
|
||||||
return false;
|
return false;
|
||||||
} else if (node.isDirectory()) {
|
} else if (node.isDirectory()) {
|
||||||
warning("File::open: Trying to open a FilesystemNode which is a directory");
|
warning("File::open: Trying to open a FilesystemNode which is a directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
} /*else if (!node.isReadable() && mode == kFileReadMode) {
|
||||||
|
warning("File::open: Trying to open an unreadable FilesystemNode object for reading");
|
||||||
|
return false;
|
||||||
|
} else if (!node.isWritable() && mode == kFileWriteMode) {
|
||||||
|
warning("File::open: Trying to open an unwritable FilesystemNode object for writing");
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
String filename(node.getName());
|
String filename(node.getName());
|
||||||
|
|
||||||
|
@ -409,7 +415,7 @@ bool File::exists(const String &filename) {
|
||||||
// FIXME: can't use isValid() here since at the time of writing
|
// FIXME: can't use isValid() here since at the time of writing
|
||||||
// FilesystemNode is to be unable to find for example files
|
// FilesystemNode is to be unable to find for example files
|
||||||
// added in extrapath
|
// added in extrapath
|
||||||
if (file.isDirectory())
|
if (file.isDirectory() && !file.exists())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Next, try to locate the file by *opening* it in read mode. This has
|
// Next, try to locate the file by *opening* it in read mode. This has
|
||||||
|
|
|
@ -161,12 +161,6 @@ bool FilesystemNode::isReadable() const {
|
||||||
return _realNode->isReadable();
|
return _realNode->isReadable();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FilesystemNode::isValid() const {
|
|
||||||
if (_realNode == 0)
|
|
||||||
return false;
|
|
||||||
return _realNode->isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FilesystemNode::isWritable() const {
|
bool FilesystemNode::isWritable() const {
|
||||||
if (_realNode == 0)
|
if (_realNode == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -193,11 +193,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool isReadable() const;
|
virtual bool isReadable() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates whether this path is valid or not for usage.
|
|
||||||
*/
|
|
||||||
bool isValid() const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether this path can be written to or not.
|
* Indicates whether this path can be written to or not.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -246,11 +246,14 @@ void md5_finish(md5_context *ctx, uint8 digest[16]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) {
|
bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) {
|
||||||
if (!file.isValid()) {
|
if(!file.exists()) {
|
||||||
warning("md5_file: using an invalid FilesystemNode");
|
warning("md5_file: using an inexistent FilesystemNode");
|
||||||
|
return false;
|
||||||
|
} else if (!file.isReadable()) {
|
||||||
|
warning("md5_file: using an unreadable FilesystemNode");
|
||||||
return false;
|
return false;
|
||||||
} else if (file.isDirectory()) {
|
} else if (file.isDirectory()) {
|
||||||
warning("md5_file: using a diretory FilesystemNode");
|
warning("md5_file: using a directory FilesystemNode");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) {
|
||||||
|
|
||||||
FilesystemNode node(dir);
|
FilesystemNode node(dir);
|
||||||
|
|
||||||
if (!node.isValid())
|
if (!node.exists() || !node.isReadable())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FSList fslist;
|
FSList fslist;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue