Factorize most of the common code in the isReadable() and isWritable() methods for the AmigaOS backend, via the getFibProtection() method.
svn-id: r29342
This commit is contained in:
parent
dc29c25b71
commit
6afbcc89a7
1 changed files with 50 additions and 48 deletions
|
@ -57,6 +57,14 @@ protected:
|
||||||
bool _bIsDirectory;
|
bool _bIsDirectory;
|
||||||
bool _bIsValid;
|
bool _bIsValid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the FileInfoBlock protection value for this FilesystemNode,
|
||||||
|
* as defined in the <proto/dos.h> header.
|
||||||
|
*
|
||||||
|
* @return -1 if there were errors, 0 or a positive integer otherwise.
|
||||||
|
*/
|
||||||
|
virtual int getFibProtection() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Creates a AmigaOSFilesystemNode with the root node as path.
|
* Creates a AmigaOSFilesystemNode with the root node as path.
|
||||||
|
@ -398,6 +406,30 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AmigaOSFilesystemNode::getFibProtection() const {
|
||||||
|
ENTER();
|
||||||
|
|
||||||
|
int fibProt = -1;
|
||||||
|
struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
|
||||||
|
if (!fib) {
|
||||||
|
debug(6, "FileInfoBlock is NULL");
|
||||||
|
LEAVE();
|
||||||
|
return fibProt;
|
||||||
|
}
|
||||||
|
|
||||||
|
BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
|
||||||
|
if (pLock) {
|
||||||
|
if (IDOS->Examine(pLock, fib) != DOSFALSE) {
|
||||||
|
fibProt = fib->fib_Protection;
|
||||||
|
}
|
||||||
|
IDOS->UnLock(pLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
IDOS->FreeDosObject(DOS_FIB, fib);
|
||||||
|
LEAVE();
|
||||||
|
return fibProt;
|
||||||
|
}
|
||||||
|
|
||||||
AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const {
|
AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const {
|
||||||
ENTER();
|
ENTER();
|
||||||
|
|
||||||
|
@ -429,64 +461,34 @@ AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AmigaOSFilesystemNode::isReadable() const {
|
bool AmigaOSFilesystemNode::isReadable() const {
|
||||||
ENTER();
|
|
||||||
|
|
||||||
bool readable = false;
|
bool readable = false;
|
||||||
struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
|
int fibProt = getFibProtection();
|
||||||
if (!fib) {
|
|
||||||
debug(6, "FileInfoBlock is NULL");
|
if (fibProt >= 0) {
|
||||||
LEAVE();
|
/* The fib_Protection flag is low-active or inverted, thus the negation.
|
||||||
return false;
|
*
|
||||||
|
* For more information, consult the compiler/include/dos/dos.h
|
||||||
|
* file from the AROS source (http://aros.sourceforge.net/).
|
||||||
|
*/
|
||||||
|
readable = !(fibProt & FIBF_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
|
|
||||||
if (pLock) {
|
|
||||||
if (IDOS->Examine(pLock, fib) != DOSFALSE) {
|
|
||||||
/* The fib_Protection flag is low-active or inverted, thus the negation.
|
|
||||||
*
|
|
||||||
* For more information, consult the compiler/include/dos/dos.h
|
|
||||||
* file from the AROS source (http://aros.sourceforge.net/).
|
|
||||||
*/
|
|
||||||
if (!(fib->fib_Protection & FIBF_READ)) {
|
|
||||||
readable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IDOS->UnLock(pLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
IDOS->FreeDosObject(DOS_FIB, fib);
|
|
||||||
LEAVE();
|
|
||||||
return readable;
|
return readable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AmigaOSFilesystemNode::isWritable() const {
|
bool AmigaOSFilesystemNode::isWritable() const {
|
||||||
ENTER();
|
|
||||||
|
|
||||||
bool writable = false;
|
bool writable = false;
|
||||||
struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
|
int fibProt = getFibProtection();
|
||||||
if (!fib) {
|
|
||||||
debug(6, "FileInfoBlock is NULL");
|
if (fibProt >= 0) {
|
||||||
LEAVE();
|
/* The fib_Protection flag is low-active or inverted, thus the negation.
|
||||||
return false;
|
*
|
||||||
|
* For more information, consult the compiler/include/dos/dos.h
|
||||||
|
* file from the AROS source (http://aros.sourceforge.net/).
|
||||||
|
*/
|
||||||
|
writable = !(fibProt & FIBF_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BPTR pLock = IDOS->Lock((STRPTR)_sPath.c_str(), SHARED_LOCK);
|
|
||||||
if (pLock) {
|
|
||||||
if (IDOS->Examine(pLock, fib) != DOSFALSE) {
|
|
||||||
/* The fib_Protection flag is low-active or inverted, thus the negation.
|
|
||||||
*
|
|
||||||
* For more information, consult the compiler/include/dos/dos.h
|
|
||||||
* file from the AROS source (http://aros.sourceforge.net/).
|
|
||||||
*/
|
|
||||||
if (!(fib->fib_Protection & FIBF_WRITE)) {
|
|
||||||
writable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IDOS->UnLock(pLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
IDOS->FreeDosObject(DOS_FIB, fib);
|
|
||||||
LEAVE();
|
|
||||||
return writable;
|
return writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue