Added Type(), IsFile(), IsDirectory(), and GetDirectoryIterator()
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3941 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#include "Icb.h"
|
#include "Icb.h"
|
||||||
|
|
||||||
|
#include "DirectoryIterator.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include "Volume.h"
|
#include "Volume.h"
|
||||||
|
|
||||||
using namespace Udf;
|
using namespace Udf;
|
||||||
@@ -8,7 +10,7 @@ Icb::Icb(Volume *volume, udf_long_address address)
|
|||||||
: fVolume(NULL)
|
: fVolume(NULL)
|
||||||
, fIcbData(volume ? volume->BlockSize() : 0)
|
, fIcbData(volume ? volume->BlockSize() : 0)
|
||||||
, fInitStatus(B_NO_INIT)
|
, fInitStatus(B_NO_INIT)
|
||||||
, fId((address.block() << 16) & (address.partition()))
|
, fId(to_vnode_id(address))
|
||||||
{
|
{
|
||||||
DEBUG_INIT_ETC(CF_PUBLIC, "Icb", ("Volume*(%p), long_address(block: %ld, partition: %d, length: %ld)", volume, address.block(), address.partition(), address.length()));
|
DEBUG_INIT_ETC(CF_PUBLIC, "Icb", ("Volume*(%p), long_address(block: %ld, partition: %d, length: %ld)", volume, address.block(), address.partition(), address.length()));
|
||||||
status_t err = volume ? B_OK : B_BAD_VALUE;
|
status_t err = volume ? B_OK : B_BAD_VALUE;
|
||||||
@@ -31,3 +33,22 @@ Icb::InitCheck()
|
|||||||
{
|
{
|
||||||
return fInitStatus;
|
return fInitStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Icb::GetDirectoryIterator(DirectoryIterator **iterator)
|
||||||
|
{
|
||||||
|
status_t err = iterator ? B_OK : B_BAD_VALUE;
|
||||||
|
|
||||||
|
if (!err) {
|
||||||
|
*iterator = new DirectoryIterator(this);
|
||||||
|
if (*iterator) {
|
||||||
|
err = fIteratorList.PushBack(*iterator);
|
||||||
|
} else {
|
||||||
|
err = B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ extern "C" {
|
|||||||
|
|
||||||
#include "DiskStructures.h"
|
#include "DiskStructures.h"
|
||||||
#include "MemoryChunk.h"
|
#include "MemoryChunk.h"
|
||||||
|
#include "SinglyLinkedList.h"
|
||||||
|
|
||||||
namespace Udf {
|
namespace Udf {
|
||||||
|
|
||||||
|
class DirectoryIterator;
|
||||||
class Volume;
|
class Volume;
|
||||||
|
|
||||||
class Icb {
|
class Icb {
|
||||||
@@ -33,13 +35,29 @@ public:
|
|||||||
Icb(Volume *volume, udf_long_address address);
|
Icb(Volume *volume, udf_long_address address);
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
vnode_id Id() { return fId; }
|
vnode_id Id() { return fId; }
|
||||||
|
|
||||||
|
// categorization
|
||||||
|
uint8 Type() { return IcbTag().file_type(); }
|
||||||
|
bool IsFile() { return InitCheck() == B_OK && Type() == ICB_TYPE_REGULAR_FILE; }
|
||||||
|
bool IsDirectory() { return InitCheck() == B_OK
|
||||||
|
&& (Type() == ICB_TYPE_DIRECTORY || Type() == ICB_TYPE_STREAM_DIRECTORY); }
|
||||||
|
|
||||||
|
// directories
|
||||||
|
status_t GetDirectoryIterator(DirectoryIterator **iterator);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Icb(); // unimplemented
|
Icb(); // unimplemented
|
||||||
|
|
||||||
|
udf_icb_entry_tag& IcbTag() { return (reinterpret_cast<udf_icb_header*>(fIcbData.Data()))->icb_tag(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Volume *fVolume;
|
Volume *fVolume;
|
||||||
MemoryChunk fIcbData;
|
MemoryChunk fIcbData;
|
||||||
status_t fInitStatus;
|
status_t fInitStatus;
|
||||||
vnode_id fId;
|
vnode_id fId;
|
||||||
|
SinglyLinkedList<Strategy::SinglyLinkedList::Auto<DirectoryIterator*> > fIteratorList;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace Udf
|
}; // namespace Udf
|
||||||
|
|||||||
Reference in New Issue
Block a user