* Even more cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30742 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -43,14 +43,14 @@ typedef DoublyLinkedList<Attribute> AttributeList;
|
|||||||
typedef DoublyLinkedList<attr_cookie> AttrCookieList;
|
typedef DoublyLinkedList<attr_cookie> AttrCookieList;
|
||||||
|
|
||||||
struct riff_header {
|
struct riff_header {
|
||||||
uint32 magic;
|
uint32 magic;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
uint32 id;
|
uint32 id;
|
||||||
} _PACKED;
|
} _PACKED;
|
||||||
|
|
||||||
struct riff_chunk {
|
struct riff_chunk {
|
||||||
uint32 fourcc;
|
uint32 fourcc;
|
||||||
uint32 length;
|
uint32 length;
|
||||||
} _PACEKD;
|
} _PACEKD;
|
||||||
|
|
||||||
struct wav_format_chunk : riff_chunk {
|
struct wav_format_chunk : riff_chunk {
|
||||||
@@ -75,160 +75,168 @@ enum attr_mode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Volume {
|
class Volume {
|
||||||
public:
|
public:
|
||||||
Volume(fs_volume* fsVolume);
|
Volume(fs_volume* fsVolume);
|
||||||
~Volume();
|
~Volume();
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
fs_volume* FSVolume() const { return fFSVolume; }
|
fs_volume* FSVolume() const { return fFSVolume; }
|
||||||
uint32 DiscID() const { return fDiscID; }
|
uint32 DiscID() const { return fDiscID; }
|
||||||
Inode& RootNode() const { return *fRootNode; }
|
Inode& RootNode() const { return *fRootNode; }
|
||||||
|
|
||||||
status_t Mount(const char* device);
|
status_t Mount(const char* device);
|
||||||
int Device() const { return fDevice; }
|
int Device() const { return fDevice; }
|
||||||
ino_t GetNextNodeID() { return fNextID++; }
|
ino_t GetNextNodeID() { return fNextID++; }
|
||||||
|
|
||||||
const char* Name() const { return fName; }
|
const char* Name() const { return fName; }
|
||||||
status_t SetName(const char* name);
|
status_t SetName(const char* name);
|
||||||
|
|
||||||
Semaphore& Lock();
|
Semaphore& Lock();
|
||||||
|
|
||||||
Inode* Find(ino_t id);
|
Inode* Find(ino_t id);
|
||||||
Inode* Find(const char* name);
|
Inode* Find(const char* name);
|
||||||
|
|
||||||
Inode* FirstEntry() const { return fFirstEntry; }
|
Inode* FirstEntry() const { return fFirstEntry; }
|
||||||
|
|
||||||
off_t NumBlocks() const { return fNumBlocks; }
|
off_t NumBlocks() const { return fNumBlocks; }
|
||||||
size_t BufferSize() const { return 32 * kFrameSize; }
|
size_t BufferSize() const { return 32 * kFrameSize; }
|
||||||
// TODO: for now
|
// TODO: for now
|
||||||
|
|
||||||
static void DetermineName(uint32 cddbId, int device, char* name,
|
static void DetermineName(uint32 cddbId, int device, char* name,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Inode* _CreateNode(Inode* parent, const char* name,
|
Inode* _CreateNode(Inode* parent, const char* name,
|
||||||
off_t start, off_t frames, int32 type);
|
off_t start, off_t frames, int32 type);
|
||||||
int _OpenAttributes(int mode,
|
int _OpenAttributes(int mode,
|
||||||
enum attr_mode attrMode = kDiscIDAttributes);
|
enum attr_mode attrMode = kDiscIDAttributes);
|
||||||
void _RestoreAttributes();
|
void _RestoreAttributes();
|
||||||
void _RestoreAttributes(int fd);
|
void _RestoreAttributes(int fd);
|
||||||
void _StoreAttributes();
|
void _StoreAttributes();
|
||||||
void _RestoreSharedAttributes();
|
void _RestoreSharedAttributes();
|
||||||
void _StoreSharedAttributes();
|
void _StoreSharedAttributes();
|
||||||
|
|
||||||
Semaphore fLock;
|
Semaphore fLock;
|
||||||
fs_volume* fFSVolume;
|
fs_volume* fFSVolume;
|
||||||
int fDevice;
|
int fDevice;
|
||||||
dev_t fID;
|
dev_t fID;
|
||||||
uint32 fDiscID;
|
uint32 fDiscID;
|
||||||
Inode* fRootNode;
|
Inode* fRootNode;
|
||||||
ino_t fNextID;
|
ino_t fNextID;
|
||||||
char* fName;
|
char* fName;
|
||||||
off_t fNumBlocks;
|
off_t fNumBlocks;
|
||||||
|
|
||||||
// root directory contents - we don't support other directories
|
// root directory contents - we don't support other directories
|
||||||
Inode* fFirstEntry;
|
Inode* fFirstEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Attribute : public DoublyLinkedListLinkImpl<Attribute> {
|
class Attribute : public DoublyLinkedListLinkImpl<Attribute> {
|
||||||
public:
|
public:
|
||||||
Attribute(const char* name, type_code type);
|
Attribute(const char* name, type_code type);
|
||||||
~Attribute();
|
~Attribute();
|
||||||
|
|
||||||
status_t InitCheck() const { return fName != NULL ? B_OK : B_NO_MEMORY; }
|
status_t InitCheck() const
|
||||||
status_t SetTo(const char* name, type_code type);
|
{ return fName != NULL ? B_OK : B_NO_MEMORY; }
|
||||||
void SetType(type_code type) { fType = type; }
|
status_t SetTo(const char* name, type_code type);
|
||||||
|
void SetType(type_code type)
|
||||||
|
{ fType = type; }
|
||||||
|
|
||||||
status_t ReadAt(off_t offset, uint8* buffer, size_t* _length);
|
status_t ReadAt(off_t offset, uint8* buffer,
|
||||||
status_t WriteAt(off_t offset, const uint8* buffer, size_t* _length);
|
size_t* _length);
|
||||||
void Truncate();
|
status_t WriteAt(off_t offset, const uint8* buffer,
|
||||||
status_t SetSize(off_t size);
|
size_t* _length);
|
||||||
|
void Truncate();
|
||||||
|
status_t SetSize(off_t size);
|
||||||
|
|
||||||
const char* Name() const { return fName; }
|
const char* Name() const { return fName; }
|
||||||
size_t Size() const { return fSize; }
|
size_t Size() const { return fSize; }
|
||||||
type_code Type() const { return fType; }
|
type_code Type() const { return fType; }
|
||||||
uint8* Data() const { return fData; }
|
uint8* Data() const { return fData; }
|
||||||
|
|
||||||
bool IsProtectedNamespace();
|
bool IsProtectedNamespace();
|
||||||
static bool IsProtectedNamespace(const char* name);
|
static bool IsProtectedNamespace(const char* name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* fName;
|
char* fName;
|
||||||
type_code fType;
|
type_code fType;
|
||||||
uint8* fData;
|
uint8* fData;
|
||||||
size_t fSize;
|
size_t fSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Inode {
|
class Inode {
|
||||||
public:
|
public:
|
||||||
Inode(Volume* volume, Inode* parent, const char* name, off_t start,
|
Inode(Volume* volume, Inode* parent,
|
||||||
off_t frames, int32 type);
|
const char* name, off_t start, off_t frames,
|
||||||
~Inode();
|
int32 type);
|
||||||
|
~Inode();
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
ino_t ID() const { return fID; }
|
ino_t ID() const { return fID; }
|
||||||
|
|
||||||
const char* Name() const { return fName; }
|
const char* Name() const { return fName; }
|
||||||
status_t SetName(const char* name);
|
status_t SetName(const char* name);
|
||||||
|
|
||||||
int32 Type() const
|
int32 Type() const
|
||||||
{ return fType; }
|
{ return fType; }
|
||||||
gid_t GroupID() const
|
gid_t GroupID() const
|
||||||
{ return fGroupID; }
|
{ return fGroupID; }
|
||||||
uid_t UserID() const
|
uid_t UserID() const
|
||||||
{ return fUserID; }
|
{ return fUserID; }
|
||||||
time_t CreationTime() const
|
time_t CreationTime() const
|
||||||
{ return fCreationTime; }
|
{ return fCreationTime; }
|
||||||
time_t ModificationTime() const
|
time_t ModificationTime() const
|
||||||
{ return fModificationTime; }
|
{ return fModificationTime; }
|
||||||
off_t StartFrame() const
|
off_t StartFrame() const
|
||||||
{ return fStartFrame; }
|
{ return fStartFrame; }
|
||||||
off_t FrameCount() const
|
off_t FrameCount() const
|
||||||
{ return fFrameCount; }
|
{ return fFrameCount; }
|
||||||
off_t Size() const
|
off_t Size() const
|
||||||
{ return fFrameCount * kFrameSize /* + WAV header */; }
|
{ return fFrameCount * kFrameSize; }
|
||||||
|
// does not include the WAV header
|
||||||
|
|
||||||
Attribute* FindAttribute(const char* name) const;
|
Attribute* FindAttribute(const char* name) const;
|
||||||
status_t AddAttribute(Attribute* attribute, bool overwrite);
|
status_t AddAttribute(Attribute* attribute, bool overwrite);
|
||||||
status_t AddAttribute(const char* name, type_code type,
|
status_t AddAttribute(const char* name, type_code type,
|
||||||
bool overwrite, const uint8* data, size_t length);
|
bool overwrite, const uint8* data,
|
||||||
status_t AddAttribute(const char* name, type_code type,
|
size_t length);
|
||||||
const char* string);
|
status_t AddAttribute(const char* name, type_code type,
|
||||||
status_t AddAttribute(const char* name, type_code type,
|
const char* string);
|
||||||
uint32 value);
|
status_t AddAttribute(const char* name, type_code type,
|
||||||
status_t RemoveAttribute(const char* name,
|
uint32 value);
|
||||||
bool checkNamespace = false);
|
status_t RemoveAttribute(const char* name,
|
||||||
|
bool checkNamespace = false);
|
||||||
|
|
||||||
void AddAttrCookie(attr_cookie* cookie);
|
void AddAttrCookie(attr_cookie* cookie);
|
||||||
void RemoveAttrCookie(attr_cookie* cookie);
|
void RemoveAttrCookie(attr_cookie* cookie);
|
||||||
void RewindAttrCookie(attr_cookie* cookie);
|
void RewindAttrCookie(attr_cookie* cookie);
|
||||||
|
|
||||||
AttributeList::ConstIterator Attributes() const
|
AttributeList::ConstIterator Attributes() const
|
||||||
{ return fAttributes.GetIterator(); }
|
{ return fAttributes.GetIterator(); }
|
||||||
|
|
||||||
const wav_header* WAVHeader() const { return &fWAVHeader; }
|
const wav_header* WAVHeader() const
|
||||||
|
{ return &fWAVHeader; }
|
||||||
|
|
||||||
Inode* Next() const { return fNext; }
|
Inode* Next() const { return fNext; }
|
||||||
void SetNext(Inode *inode) { fNext = inode; }
|
void SetNext(Inode *inode) { fNext = inode; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Inode* fNext;
|
Inode* fNext;
|
||||||
ino_t fID;
|
ino_t fID;
|
||||||
int32 fType;
|
int32 fType;
|
||||||
char *fName;
|
char* fName;
|
||||||
gid_t fGroupID;
|
gid_t fGroupID;
|
||||||
uid_t fUserID;
|
uid_t fUserID;
|
||||||
time_t fCreationTime;
|
time_t fCreationTime;
|
||||||
time_t fModificationTime;
|
time_t fModificationTime;
|
||||||
off_t fStartFrame;
|
off_t fStartFrame;
|
||||||
off_t fFrameCount;
|
off_t fFrameCount;
|
||||||
AttributeList fAttributes;
|
AttributeList fAttributes;
|
||||||
AttrCookieList fAttrCookies;
|
AttrCookieList fAttrCookies;
|
||||||
wav_header fWAVHeader;
|
wav_header fWAVHeader;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dir_cookie {
|
struct dir_cookie {
|
||||||
Inode *current;
|
Inode* current;
|
||||||
int state; // iteration state
|
int state; // iteration state
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -241,13 +249,13 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct attr_cookie : DoublyLinkedListLinkImpl<attr_cookie> {
|
struct attr_cookie : DoublyLinkedListLinkImpl<attr_cookie> {
|
||||||
Attribute *current;
|
Attribute* current;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct file_cookie {
|
struct file_cookie {
|
||||||
int open_mode;
|
int open_mode;
|
||||||
off_t buffer_offset;
|
off_t buffer_offset;
|
||||||
void *buffer;
|
void* buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32 kMaxAttributeSize = 65536;
|
static const uint32 kMaxAttributeSize = 65536;
|
||||||
|
|||||||
Reference in New Issue
Block a user