Style fixes to Storage Kit classes.
No functional changes intended. * Some variable renaming for clarity and consistency. * Pointer style fixes. * Added private method documentation back to cpp files for some methods.
This commit is contained in:
parent
d2d1af830b
commit
a30a4a41f9
@ -20,7 +20,7 @@ typedef enum {
|
||||
B_SYSTEM_BOOT_DIRECTORY,
|
||||
B_SYSTEM_FONTS_DIRECTORY,
|
||||
B_SYSTEM_LIB_DIRECTORY,
|
||||
B_SYSTEM_SERVERS_DIRECTORY,
|
||||
B_SYSTEM_SERVERS_DIRECTORY,
|
||||
B_SYSTEM_APPS_DIRECTORY,
|
||||
B_SYSTEM_BIN_DIRECTORY,
|
||||
B_SYSTEM_DOCUMENTATION_DIRECTORY = 1010,
|
||||
@ -86,7 +86,7 @@ typedef enum {
|
||||
B_USER_NONPACKAGED_DEVELOP_DIRECTORY,
|
||||
B_USER_DEVELOP_DIRECTORY,
|
||||
B_USER_DOCUMENTATION_DIRECTORY,
|
||||
B_USER_SERVERS_DIRECTORY,
|
||||
B_USER_SERVERS_DIRECTORY,
|
||||
B_USER_APPS_DIRECTORY,
|
||||
B_USER_BIN_DIRECTORY,
|
||||
B_USER_PREFERENCES_DIRECTORY,
|
||||
@ -108,7 +108,7 @@ typedef enum {
|
||||
B_BEOS_BOOT_DIRECTORY,
|
||||
B_BEOS_FONTS_DIRECTORY,
|
||||
B_BEOS_LIB_DIRECTORY,
|
||||
B_BEOS_SERVERS_DIRECTORY,
|
||||
B_BEOS_SERVERS_DIRECTORY,
|
||||
B_BEOS_APPS_DIRECTORY,
|
||||
B_BEOS_BIN_DIRECTORY,
|
||||
B_BEOS_ETC_DIRECTORY,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2006 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _MIME_TYPE_H
|
||||
@ -14,6 +14,7 @@
|
||||
#include <File.h>
|
||||
#include <Entry.h>
|
||||
|
||||
|
||||
class BBitmap;
|
||||
class BResources;
|
||||
class BAppFileInfo;
|
||||
@ -32,12 +33,12 @@ enum app_verb {
|
||||
B_OPEN
|
||||
};
|
||||
|
||||
extern const char *B_APP_MIME_TYPE; // platform dependent
|
||||
extern const char *B_PEF_APP_MIME_TYPE; // "application/x-be-executable"
|
||||
extern const char *B_PE_APP_MIME_TYPE; // "application/x-vnd.be-peexecutable"
|
||||
extern const char *B_ELF_APP_MIME_TYPE; // "application/x-vnd.be-elfexecutable"
|
||||
extern const char *B_RESOURCE_MIME_TYPE;// "application/x-be-resource"
|
||||
extern const char *B_FILE_MIME_TYPE; // "application/octet-stream"
|
||||
extern const char* B_APP_MIME_TYPE; // platform dependent
|
||||
extern const char* B_PEF_APP_MIME_TYPE; // "application/x-be-executable"
|
||||
extern const char* B_PE_APP_MIME_TYPE; // "application/x-vnd.be-peexecutable"
|
||||
extern const char* B_ELF_APP_MIME_TYPE; // "application/x-vnd.be-elfexecutable"
|
||||
extern const char* B_RESOURCE_MIME_TYPE;// "application/x-be-resource"
|
||||
extern const char* B_FILE_MIME_TYPE; // "application/octet-stream"
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
@ -71,113 +72,114 @@ enum {
|
||||
};
|
||||
|
||||
class BMimeType {
|
||||
public:
|
||||
BMimeType();
|
||||
BMimeType(const char *mimeType);
|
||||
virtual ~BMimeType();
|
||||
public:
|
||||
BMimeType();
|
||||
BMimeType(const char* mimeType);
|
||||
virtual ~BMimeType();
|
||||
|
||||
status_t SetTo(const char *mimeType);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
status_t SetTo(const char* mimeType);
|
||||
void Unset();
|
||||
status_t InitCheck() const;
|
||||
|
||||
/* these functions simply perform string manipulations*/
|
||||
const char *Type() const;
|
||||
bool IsValid() const;
|
||||
bool IsSupertypeOnly() const;
|
||||
status_t GetSupertype(BMimeType *superType) const;
|
||||
/* these functions simply perform string manipulations*/
|
||||
const char* Type() const;
|
||||
bool IsValid() const;
|
||||
bool IsSupertypeOnly() const;
|
||||
status_t GetSupertype(BMimeType* supertype) const;
|
||||
|
||||
bool operator==(const BMimeType &type) const;
|
||||
bool operator==(const char *type) const;
|
||||
bool operator==(const BMimeType &type) const;
|
||||
bool operator==(const char* type) const;
|
||||
|
||||
bool Contains(const BMimeType *type) const;
|
||||
bool Contains(const BMimeType* type) const;
|
||||
|
||||
/* These functions are for managing data in the meta mime file */
|
||||
status_t Install();
|
||||
status_t Delete();
|
||||
bool IsInstalled() const;
|
||||
status_t GetIcon(BBitmap* icon, icon_size size) const;
|
||||
status_t GetIcon(uint8** _data, size_t* _size) const;
|
||||
status_t GetPreferredApp(char *signature, app_verb verb = B_OPEN) const;
|
||||
status_t GetAttrInfo(BMessage *info) const;
|
||||
status_t GetFileExtensions(BMessage *extensions) const;
|
||||
status_t GetShortDescription(char *description) const;
|
||||
status_t GetLongDescription(char *description) const;
|
||||
status_t GetSupportingApps(BMessage *signatures) const;
|
||||
/* These functions are for managing data in the meta mime file */
|
||||
status_t Install();
|
||||
status_t Delete();
|
||||
bool IsInstalled() const;
|
||||
status_t GetIcon(BBitmap* icon, icon_size size) const;
|
||||
status_t GetIcon(uint8** _data, size_t* _size) const;
|
||||
status_t GetPreferredApp(char* signature, app_verb verb = B_OPEN) const;
|
||||
status_t GetAttrInfo(BMessage* info) const;
|
||||
status_t GetFileExtensions(BMessage* extensions) const;
|
||||
status_t GetShortDescription(char* description) const;
|
||||
status_t GetLongDescription(char* description) const;
|
||||
status_t GetSupportingApps(BMessage* signatures) const;
|
||||
|
||||
status_t SetIcon(const BBitmap *icon, icon_size size);
|
||||
status_t SetIcon(const uint8* data, size_t size);
|
||||
status_t SetPreferredApp(const char *signature, app_verb verb = B_OPEN);
|
||||
status_t SetAttrInfo(const BMessage *info);
|
||||
status_t SetFileExtensions(const BMessage *extensions);
|
||||
status_t SetShortDescription(const char *description);
|
||||
status_t SetLongDescription(const char *description);
|
||||
status_t SetIcon(const BBitmap* icon, icon_size size);
|
||||
status_t SetIcon(const uint8* data, size_t size);
|
||||
status_t SetPreferredApp(const char* signature, app_verb verb = B_OPEN);
|
||||
status_t SetAttrInfo(const BMessage* info);
|
||||
status_t SetFileExtensions(const BMessage* extensions);
|
||||
status_t SetShortDescription(const char* description);
|
||||
status_t SetLongDescription(const char* description);
|
||||
|
||||
static status_t GetInstalledSupertypes(BMessage *supertypes);
|
||||
static status_t GetInstalledTypes(BMessage *types);
|
||||
static status_t GetInstalledTypes(const char* supertype,
|
||||
BMessage* subtypes);
|
||||
static status_t GetWildcardApps(BMessage* wildcardApps);
|
||||
static bool IsValid(const char *mimeType);
|
||||
static status_t GetInstalledSupertypes(BMessage* supertypes);
|
||||
static status_t GetInstalledTypes(BMessage* types);
|
||||
static status_t GetInstalledTypes(const char* supertype,
|
||||
BMessage* subtypes);
|
||||
static status_t GetWildcardApps(BMessage* wildcardApps);
|
||||
static bool IsValid(const char* mimeType);
|
||||
|
||||
status_t GetAppHint(entry_ref *ref) const;
|
||||
status_t SetAppHint(const entry_ref *ref);
|
||||
status_t GetAppHint(entry_ref* ref) const;
|
||||
status_t SetAppHint(const entry_ref* ref);
|
||||
|
||||
/* for application signatures only. */
|
||||
status_t GetIconForType(const char* type, BBitmap* icon,
|
||||
icon_size which) const;
|
||||
status_t GetIconForType(const char* type, uint8** _data,
|
||||
size_t* _size) const;
|
||||
status_t SetIconForType(const char* type, const BBitmap* icon,
|
||||
icon_size which);
|
||||
status_t SetIconForType(const char* type, const uint8* data,
|
||||
size_t size);
|
||||
/* for application signatures only. */
|
||||
status_t GetIconForType(const char* type, BBitmap* icon,
|
||||
icon_size which) const;
|
||||
status_t GetIconForType(const char* type, uint8** _data,
|
||||
size_t* _size) const;
|
||||
status_t SetIconForType(const char* type, const BBitmap* icon,
|
||||
icon_size which);
|
||||
status_t SetIconForType(const char* type, const uint8* data,
|
||||
size_t size);
|
||||
|
||||
/* sniffer rule manipulation */
|
||||
status_t GetSnifferRule(BString *result) const;
|
||||
status_t SetSnifferRule(const char *);
|
||||
static status_t CheckSnifferRule(const char *rule, BString *parseError);
|
||||
/* sniffer rule manipulation */
|
||||
status_t GetSnifferRule(BString* result) const;
|
||||
status_t SetSnifferRule(const char*);
|
||||
static status_t CheckSnifferRule(const char* rule, BString* parseError);
|
||||
|
||||
/* calls to ask the sniffer to identify the MIME type of a file or data in
|
||||
memory */
|
||||
static status_t GuessMimeType(const entry_ref *file, BMimeType *type);
|
||||
static status_t GuessMimeType(const void *buffer, int32 length,
|
||||
BMimeType *type);
|
||||
static status_t GuessMimeType(const char *filename, BMimeType *type);
|
||||
/* calls to ask the sniffer to identify the MIME type of a file or data in
|
||||
memory */
|
||||
static status_t GuessMimeType(const entry_ref* file, BMimeType* type);
|
||||
static status_t GuessMimeType(const void* buffer, int32 length,
|
||||
BMimeType* type);
|
||||
static status_t GuessMimeType(const char* filename, BMimeType* type);
|
||||
|
||||
static status_t StartWatching(BMessenger target);
|
||||
static status_t StopWatching(BMessenger target);
|
||||
static status_t StartWatching(BMessenger target);
|
||||
static status_t StopWatching(BMessenger target);
|
||||
|
||||
/* Deprecated. Use SetTo() instead. */
|
||||
status_t SetType(const char *mimeType);
|
||||
/* Deprecated. Use SetTo() instead. */
|
||||
status_t SetType(const char* mimeType);
|
||||
|
||||
private:
|
||||
BMimeType(const char* mimeType, const char* mimePath);
|
||||
// if mimePath is NULL, defaults to "/boot/home/config/settings/beos_mime/"
|
||||
private:
|
||||
BMimeType(const char* mimeType, const char* mimePath);
|
||||
// if mimePath is NULL, defaults to "/boot/home/config/settings/beos_mime/"
|
||||
|
||||
friend class MimeTypeTest;
|
||||
// for testing only
|
||||
friend class MimeTypeTest;
|
||||
// for testing only
|
||||
|
||||
friend class BAppFileInfo;
|
||||
friend class BAppFileInfo;
|
||||
|
||||
virtual void _ReservedMimeType1();
|
||||
virtual void _ReservedMimeType2();
|
||||
virtual void _ReservedMimeType3();
|
||||
virtual void _ReservedMimeType1();
|
||||
virtual void _ReservedMimeType2();
|
||||
virtual void _ReservedMimeType3();
|
||||
|
||||
BMimeType& operator=(const BMimeType& source);
|
||||
BMimeType(const BMimeType& source);
|
||||
BMimeType& operator=(const BMimeType& source);
|
||||
BMimeType(const BMimeType& source);
|
||||
|
||||
status_t GetSupportedTypes(BMessage* types);
|
||||
status_t SetSupportedTypes(const BMessage* types, bool fullSync = true);
|
||||
status_t GetSupportedTypes(BMessage* types);
|
||||
status_t SetSupportedTypes(const BMessage* types, bool fullSync = true);
|
||||
|
||||
static status_t GetAssociatedTypes(const char* extension, BMessage* types);
|
||||
static status_t GetAssociatedTypes(const char* extension, BMessage* types);
|
||||
|
||||
private:
|
||||
char* fType;
|
||||
BFile* fMeta;
|
||||
void* _unused;
|
||||
entry_ref fRef;
|
||||
status_t fCStatus;
|
||||
uint32 _reserved[4];
|
||||
private:
|
||||
char* fType;
|
||||
BFile* fMeta;
|
||||
void* _unused;
|
||||
entry_ref fRef;
|
||||
status_t fCStatus;
|
||||
uint32 _reserved[4];
|
||||
};
|
||||
|
||||
|
||||
#endif // _MIME_TYPE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NODE_H
|
||||
@ -18,12 +18,12 @@ struct entry_ref;
|
||||
struct node_ref {
|
||||
node_ref();
|
||||
node_ref(dev_t device, ino_t node);
|
||||
node_ref(const node_ref &ref);
|
||||
node_ref(const node_ref &other);
|
||||
|
||||
bool operator==(const node_ref& ref) const;
|
||||
bool operator!=(const node_ref& ref) const;
|
||||
bool operator<(const node_ref& ref) const;
|
||||
node_ref& operator=(const node_ref& ref);
|
||||
bool operator==(const node_ref& other) const;
|
||||
bool operator!=(const node_ref& other) const;
|
||||
bool operator<(const node_ref& other) const;
|
||||
node_ref& operator=(const node_ref& other);
|
||||
|
||||
dev_t device;
|
||||
ino_t node;
|
||||
@ -100,17 +100,21 @@ private:
|
||||
status_t _SetTo(int fd, const char* path, bool traverse);
|
||||
status_t _SetTo(const entry_ref* ref, bool traverse);
|
||||
|
||||
virtual status_t set_stat(struct stat& st, uint32 what);
|
||||
virtual status_t set_stat(struct stat& stat, uint32 what);
|
||||
|
||||
status_t _GetStat(struct stat* st) const;
|
||||
virtual status_t _GetStat(struct stat_beos* st) const;
|
||||
status_t _GetStat(struct stat* stat) const;
|
||||
virtual status_t _GetStat(struct stat_beos* stat) const;
|
||||
status_t InitAttrDir();
|
||||
|
||||
private:
|
||||
uint32 rudeData[4];
|
||||
int fFd;
|
||||
// Ffile descriptor for the given node
|
||||
int fAttrFd;
|
||||
// file descriptor for the attribute directory of the node,
|
||||
// initialized lazily
|
||||
status_t fCStatus;
|
||||
// the node's initialization status
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2010 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NODE_INFO_H
|
||||
@ -31,9 +31,9 @@ public:
|
||||
virtual status_t GetType(char* type) const;
|
||||
virtual status_t SetType(const char* type);
|
||||
virtual status_t GetIcon(BBitmap* icon,
|
||||
icon_size size = B_LARGE_ICON) const;
|
||||
icon_size which = B_LARGE_ICON) const;
|
||||
virtual status_t SetIcon(const BBitmap* icon,
|
||||
icon_size size = B_LARGE_ICON);
|
||||
icon_size which = B_LARGE_ICON);
|
||||
status_t GetIcon(uint8** data, size_t* size,
|
||||
type_code* type) const;
|
||||
status_t SetIcon(const uint8* data, size_t size);
|
||||
@ -46,10 +46,10 @@ public:
|
||||
status_t SetAppHint(const entry_ref* ref);
|
||||
|
||||
status_t GetTrackerIcon(BBitmap* icon,
|
||||
icon_size size = B_LARGE_ICON) const;
|
||||
icon_size which = B_LARGE_ICON) const;
|
||||
static status_t GetTrackerIcon(const entry_ref* ref,
|
||||
BBitmap* icon,
|
||||
icon_size size = B_LARGE_ICON);
|
||||
icon_size which = B_LARGE_ICON);
|
||||
private:
|
||||
friend class BAppFileInfo;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2010, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2003-2010 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _NODE_MONITOR_H
|
||||
@ -32,25 +32,31 @@ enum {
|
||||
// The presence and meaning of the other fields in that message specifying what
|
||||
// exactly caused the notification depend on this value.
|
||||
|
||||
#define B_ENTRY_CREATED 1
|
||||
#define B_ENTRY_REMOVED 2
|
||||
#define B_ENTRY_MOVED 3
|
||||
#define B_STAT_CHANGED 4
|
||||
#define B_ATTR_CHANGED 5
|
||||
#define B_DEVICE_MOUNTED 6
|
||||
#define B_DEVICE_UNMOUNTED 7
|
||||
enum {
|
||||
B_ENTRY_CREATED = 1,
|
||||
B_ENTRY_REMOVED,
|
||||
B_ENTRY_MOVED,
|
||||
B_STAT_CHANGED,
|
||||
B_ATTR_CHANGED,
|
||||
B_DEVICE_MOUNTED,
|
||||
B_DEVICE_UNMOUNTED
|
||||
};
|
||||
|
||||
|
||||
// More specific info in the "cause" field of B_ATTR_CHANGED notification
|
||||
// messages. (Haiku only)
|
||||
#define B_ATTR_CREATED 1
|
||||
#define B_ATTR_REMOVED 2
|
||||
// B_ATTR_CHANGED is reused
|
||||
|
||||
enum {
|
||||
B_ATTR_CREATED = 1,
|
||||
B_ATTR_REMOVED,
|
||||
// B_ATTR_CHANGED
|
||||
};
|
||||
|
||||
|
||||
// More specific info in the "fields" field of B_STAT_CHANGED notification
|
||||
// messages, specifying what parts of the stat data have actually been
|
||||
// changed. (Haiku only)
|
||||
|
||||
enum {
|
||||
B_STAT_MODE = 0x0001,
|
||||
B_STAT_UID = 0x0002,
|
||||
@ -82,16 +88,17 @@ class BHandler;
|
||||
|
||||
extern status_t watch_volume(dev_t volume, uint32 flags, BMessenger target);
|
||||
extern status_t watch_volume(dev_t volume, uint32 flags,
|
||||
const BHandler *handler, const BLooper *looper = NULL);
|
||||
const BHandler* handler, const BLooper* looper = NULL);
|
||||
|
||||
extern status_t watch_node(const node_ref *node, uint32 flags,
|
||||
BMessenger target);
|
||||
extern status_t watch_node(const node_ref *node, uint32 flags,
|
||||
const BHandler *handler, const BLooper *looper = NULL);
|
||||
extern status_t watch_node(const node_ref* node, uint32 flags,
|
||||
BMessenger target);
|
||||
extern status_t watch_node(const node_ref* node, uint32 flags,
|
||||
const BHandler* handler, const BLooper* looper = NULL);
|
||||
|
||||
extern status_t stop_watching(BMessenger target);
|
||||
extern status_t stop_watching(const BHandler *handler, const BLooper *looper = NULL);
|
||||
extern status_t stop_watching(const BHandler* handler, const BLooper* looper = NULL);
|
||||
|
||||
#endif // __cplusplus && !_KERNEL_MODE
|
||||
|
||||
|
||||
#endif // _NODE_MONITOR_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2014 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _STATABLE_H
|
||||
@ -18,58 +18,58 @@ class BVolume;
|
||||
|
||||
|
||||
class BStatable {
|
||||
public:
|
||||
public:
|
||||
#if __GNUC__ > 3
|
||||
virtual ~BStatable();
|
||||
virtual ~BStatable();
|
||||
#endif
|
||||
|
||||
private:
|
||||
virtual status_t _GetStat(struct stat_beos *st) const = 0;
|
||||
// provided for BeOS compatibility
|
||||
virtual status_t _GetStat(struct stat_beos* stat) const = 0;
|
||||
// provided for BeOS compatibility
|
||||
|
||||
public:
|
||||
virtual status_t GetStat(struct stat *st) const = 0;
|
||||
virtual status_t GetStat(struct stat* stat) const = 0;
|
||||
|
||||
bool IsFile() const;
|
||||
bool IsDirectory() const;
|
||||
bool IsSymLink() const;
|
||||
bool IsFile() const;
|
||||
bool IsDirectory() const;
|
||||
bool IsSymLink() const;
|
||||
|
||||
status_t GetNodeRef(node_ref *ref) const;
|
||||
status_t GetNodeRef(node_ref* ref) const;
|
||||
|
||||
status_t GetOwner(uid_t *owner) const;
|
||||
status_t SetOwner(uid_t owner);
|
||||
status_t GetOwner(uid_t* owner) const;
|
||||
status_t SetOwner(uid_t owner);
|
||||
|
||||
status_t GetGroup(gid_t *group) const;
|
||||
status_t SetGroup(gid_t group);
|
||||
status_t GetGroup(gid_t* group) const;
|
||||
status_t SetGroup(gid_t group);
|
||||
|
||||
status_t GetPermissions(mode_t *perms) const;
|
||||
status_t SetPermissions(mode_t perms);
|
||||
status_t GetPermissions(mode_t* permissions) const;
|
||||
status_t SetPermissions(mode_t permissions);
|
||||
|
||||
status_t GetSize(off_t *size) const;
|
||||
status_t GetSize(off_t* size) const;
|
||||
|
||||
status_t GetModificationTime(time_t *mtime) const;
|
||||
status_t SetModificationTime(time_t mtime);
|
||||
status_t GetModificationTime(time_t* mtime) const;
|
||||
status_t SetModificationTime(time_t mtime);
|
||||
|
||||
status_t GetCreationTime(time_t *ctime) const;
|
||||
status_t SetCreationTime(time_t ctime);
|
||||
status_t GetCreationTime(time_t* ctime) const;
|
||||
status_t SetCreationTime(time_t ctime);
|
||||
|
||||
status_t GetAccessTime(time_t *atime) const;
|
||||
status_t SetAccessTime(time_t atime);
|
||||
status_t GetAccessTime(time_t* atime) const;
|
||||
status_t SetAccessTime(time_t atime);
|
||||
|
||||
status_t GetVolume(BVolume *vol) const;
|
||||
status_t GetVolume(BVolume* volume) const;
|
||||
|
||||
class Private;
|
||||
class Private;
|
||||
|
||||
private:
|
||||
friend class BEntry;
|
||||
friend class BNode;
|
||||
friend class Private;
|
||||
private:
|
||||
friend class BEntry;
|
||||
friend class BNode;
|
||||
friend class Private;
|
||||
|
||||
virtual void _OhSoStatable2();
|
||||
virtual void _OhSoStatable3();
|
||||
uint32 _reserved[4];
|
||||
virtual void _OhSoStatable2();
|
||||
virtual void _OhSoStatable3();
|
||||
uint32 _reserved[4];
|
||||
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
};
|
||||
|
||||
#endif // _STATABLE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2007 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SYM_LINK_H
|
||||
@ -16,20 +16,20 @@ class BPath;
|
||||
class BSymLink : public BNode {
|
||||
public:
|
||||
BSymLink();
|
||||
BSymLink(const BSymLink &link);
|
||||
BSymLink(const entry_ref *ref);
|
||||
BSymLink(const BEntry *entry);
|
||||
BSymLink(const char *path);
|
||||
BSymLink(const BDirectory *dir,
|
||||
const char *path);
|
||||
BSymLink(const BSymLink& other);
|
||||
BSymLink(const entry_ref* ref);
|
||||
BSymLink(const BEntry* entry);
|
||||
BSymLink(const char* path);
|
||||
BSymLink(const BDirectory* dir,
|
||||
const char* path);
|
||||
virtual ~BSymLink();
|
||||
|
||||
ssize_t ReadLink(char *buf, size_t size);
|
||||
ssize_t ReadLink(char* buf, size_t size);
|
||||
|
||||
ssize_t MakeLinkedPath(const char *dirPath,
|
||||
BPath *path);
|
||||
ssize_t MakeLinkedPath(const BDirectory *dir,
|
||||
BPath *path);
|
||||
ssize_t MakeLinkedPath(const char* dirPath,
|
||||
BPath* path);
|
||||
ssize_t MakeLinkedPath(const BDirectory* dir,
|
||||
BPath* path);
|
||||
|
||||
bool IsAbsolute();
|
||||
|
||||
|
@ -958,6 +958,7 @@ void BAppFileInfo::_ReservedAppFileInfo2() {}
|
||||
void BAppFileInfo::_ReservedAppFileInfo3() {}
|
||||
|
||||
|
||||
//! Privatized assignment operator to prevent usage.
|
||||
BAppFileInfo&
|
||||
BAppFileInfo::operator=(const BAppFileInfo&)
|
||||
{
|
||||
@ -965,11 +966,25 @@ BAppFileInfo::operator=(const BAppFileInfo&)
|
||||
}
|
||||
|
||||
|
||||
//! Privatized copy constructor to prevent usage.
|
||||
BAppFileInfo::BAppFileInfo(const BAppFileInfo&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*! Initializes a BMimeType to the signature of the associated file.
|
||||
|
||||
\warning The parameter \a meta is not checked.
|
||||
|
||||
\param meta A pointer to a pre-allocated BMimeType that shall be
|
||||
initialized to the signature of the associated file.
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_BAD_VALUE \c NULL \a meta
|
||||
\retval B_ENTRY_NOT_FOUND The file has not signature or the signature is
|
||||
(not installed in the MIME database.) no valid MIME string.
|
||||
*/
|
||||
status_t
|
||||
BAppFileInfo::GetMetaMime(BMimeType* meta) const
|
||||
{
|
||||
@ -985,6 +1000,31 @@ BAppFileInfo::GetMetaMime(BMimeType* meta) const
|
||||
}
|
||||
|
||||
|
||||
/*! Reads data from an attribute or resource.
|
||||
|
||||
\note The data is read from the location specified by \a fWhere.
|
||||
|
||||
\warning The object must be properly initialized. The parameters are
|
||||
\b NOT checked.
|
||||
|
||||
\param name The name of the attribute/resource to be read.
|
||||
\param id The resource ID of the resource to be read. It is ignored
|
||||
when < 0.
|
||||
\param type The type of the attribute/resource to be read.
|
||||
\param buffer A pre-allocated buffer for the data to be read.
|
||||
\param bufferSize The size of the supplied buffer.
|
||||
\param bytesRead A reference parameter, set to the number of bytes
|
||||
actually read.
|
||||
\param allocatedBuffer If not \c NULL, the method allocates a buffer
|
||||
large enough too store the whole data and writes a pointer to it
|
||||
into this variable. If \c NULL, the supplied buffer is used.
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_ENTRY_NOT_FOUND The entry was not found.
|
||||
\retval B_NO_MEMORY Ran out of memory allocating the buffer.
|
||||
\retval B_BAD_VALUE \a type did not match.
|
||||
*/
|
||||
status_t
|
||||
BAppFileInfo::_ReadData(const char* name, int32 id, type_code type,
|
||||
void* buffer, size_t bufferSize, size_t& bytesRead, void** allocatedBuffer)
|
||||
@ -1081,6 +1121,26 @@ BAppFileInfo::_ReadData(const char* name, int32 id, type_code type,
|
||||
}
|
||||
|
||||
|
||||
/*! Writes data to an attribute or resource.
|
||||
|
||||
\note The data is written to the location(s) specified by \a fWhere.
|
||||
|
||||
\warning The object must be properly initialized. The parameters are
|
||||
\b NOT checked.
|
||||
|
||||
\param name The name of the attribute/resource to be written.
|
||||
\param id The resource ID of the resource to be written.
|
||||
\param type The type of the attribute/resource to be written.
|
||||
\param buffer A buffer containing the data to be written.
|
||||
\param bufferSize The size of the supplied buffer.
|
||||
\param findID If set to \c true use the ID that is already assigned to the
|
||||
\a name / \a type pair or take the first unused ID >= \a id.
|
||||
If \c false, \a id is used.
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_ERROR An error occurred while trying to write the data.
|
||||
*/
|
||||
status_t
|
||||
BAppFileInfo::_WriteData(const char* name, int32 id, type_code type,
|
||||
const void* buffer, size_t bufferSize, bool findID)
|
||||
@ -1118,6 +1178,21 @@ BAppFileInfo::_WriteData(const char* name, int32 id, type_code type,
|
||||
}
|
||||
|
||||
|
||||
/*! Removes an attribute or resource.
|
||||
|
||||
\note The removal location is specified by \a fWhere.
|
||||
|
||||
\warning The object must be properly initialized. The parameters are
|
||||
\b NOT checked.
|
||||
|
||||
\param name The name of the attribute/resource to be remove.
|
||||
\param type The type of the attribute/resource to be removed.
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_NO_INIT Not using attributes and not using resources.
|
||||
\retval B_ENTRY_NOT_FOUND The attribute or resource was not found.
|
||||
*/
|
||||
status_t
|
||||
BAppFileInfo::_RemoveData(const char* name, type_code type)
|
||||
{
|
||||
|
@ -502,6 +502,16 @@ void BEntry::_PennyEntry5(){}
|
||||
void BEntry::_PennyEntry6(){}
|
||||
|
||||
|
||||
/*! Updates the BEntry with the data from the stat structure according
|
||||
to the \a what mask.
|
||||
|
||||
\param st The stat structure to set.
|
||||
\param what A mask
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_FILE_ERROR There was an error writing to the BEntry object.
|
||||
*/
|
||||
status_t
|
||||
BEntry::set_stat(struct stat& st, uint32 what)
|
||||
{
|
||||
@ -513,6 +523,30 @@ BEntry::set_stat(struct stat& st, uint32 what)
|
||||
}
|
||||
|
||||
|
||||
/*! Sets the entry to point to the entry specified by the path \a path
|
||||
relative to the given directory.
|
||||
|
||||
If \a traverse is \c true and the given entry is a symbolic link, the
|
||||
object is recursively set to point to the entry pointed to by the symlink.
|
||||
|
||||
If \a path is an absolute path, \a dirFD is ignored.
|
||||
|
||||
If \a dirFD is -1, \a path is considered relative to the current directory
|
||||
(unless it is an absolute path).
|
||||
|
||||
The ownership of the file descriptor \a dirFD is transferred to the
|
||||
method, regardless of whether it succeeds or fails. The caller must not
|
||||
close the FD afterwards.
|
||||
|
||||
\param dirFD File descriptor of a directory relative to which path is to
|
||||
be considered. May be -1 if the current directory shall be considered.
|
||||
\param path Pointer to a path relative to the given directory.
|
||||
\param traverse If \c true and the given entry is a symbolic link, the
|
||||
object is recursively set to point to the entry linked to by the
|
||||
symbolic link.
|
||||
|
||||
\returns \c B_OK on success, or an error code on failure.
|
||||
*/
|
||||
status_t
|
||||
BEntry::_SetTo(int dirFD, const char* path, bool traverse)
|
||||
{
|
||||
@ -643,6 +677,16 @@ BEntry::_SetTo(int dirFD, const char* path, bool traverse)
|
||||
}
|
||||
|
||||
|
||||
/*! Handles string allocation, deallocation, and copying for the
|
||||
leaf name of the entry.
|
||||
|
||||
\param name The leaf \a name of the entry.
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_BAD_VALUE \a name is \c NULL.
|
||||
\retval B_NO_MEMORY Ran out of memory trying to allocate \a name.
|
||||
*/
|
||||
status_t
|
||||
BEntry::_SetName(const char* name)
|
||||
{
|
||||
@ -659,6 +703,22 @@ BEntry::_SetName(const char* name)
|
||||
}
|
||||
|
||||
|
||||
/*! Renames the entry referred to by this object to the location
|
||||
specified by \a target.
|
||||
|
||||
If an entry exists at the target location, the method fails, unless
|
||||
\a clobber is \c true, in which case that entry is overwritten (doesn't
|
||||
work for non-empty directories, though).
|
||||
|
||||
If the operation was successful, this entry is made a clone of the
|
||||
supplied one and the supplied one is uninitialized.
|
||||
|
||||
\param target The entry specifying the target location.
|
||||
\param clobber If \c true, the an entry existing at the target location
|
||||
will be overwritten.
|
||||
|
||||
\return \c B_OK, if everything went fine, another error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
BEntry::_Rename(BEntry& target, bool clobber)
|
||||
{
|
||||
@ -680,6 +740,11 @@ BEntry::_Rename(BEntry& target, bool clobber)
|
||||
}
|
||||
|
||||
|
||||
/*! Debugging function, dumps the given entry to stdout.
|
||||
|
||||
\param name A pointer to a string to be printed along with the dump for
|
||||
identification purposes.
|
||||
*/
|
||||
void
|
||||
BEntry::_Dump(const char* name)
|
||||
{
|
||||
|
@ -337,7 +337,12 @@ void BFile::_PhiloFile5() {}
|
||||
void BFile::_PhiloFile6() {}
|
||||
|
||||
|
||||
// Gets the file descriptor of the BFile.
|
||||
/*! Gets the file descriptor of the BFile.
|
||||
|
||||
To be used instead of accessing the BNode's private \c fFd member directly.
|
||||
|
||||
\returns The file descriptor, or -1 if not properly initialized.
|
||||
*/
|
||||
int
|
||||
BFile::get_fd() const
|
||||
{
|
||||
@ -345,7 +350,7 @@ BFile::get_fd() const
|
||||
}
|
||||
|
||||
|
||||
// Overrides BNode::close_fd() for binary compatibility with BeOS R5.
|
||||
//! Overrides BNode::close_fd() for binary compatibility with BeOS R5.
|
||||
void
|
||||
BFile::close_fd()
|
||||
{
|
||||
|
@ -8,10 +8,6 @@
|
||||
* Axel Dörfler, axeld@pinc-software.de
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file Mime.cpp
|
||||
Mime type C functions implementation.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <new>
|
||||
@ -47,7 +43,7 @@ enum {
|
||||
|
||||
// Helper function that contacts the registrar for mime update calls
|
||||
status_t
|
||||
do_mime_update(int32 what, const char *path, int recursive,
|
||||
do_mime_update(int32 what, const char* path, int recursive,
|
||||
int synchronous, int force)
|
||||
{
|
||||
BEntry root;
|
||||
@ -85,7 +81,7 @@ do_mime_update(int32 what, const char *path, int recursive,
|
||||
|
||||
// Updates the MIME information (i.e MIME type) for one or more files.
|
||||
int
|
||||
update_mime_info(const char *path, int recursive, int synchronous, int force)
|
||||
update_mime_info(const char* path, int recursive, int synchronous, int force)
|
||||
{
|
||||
// Force recursion when given a NULL path
|
||||
if (!path)
|
||||
@ -98,7 +94,7 @@ update_mime_info(const char *path, int recursive, int synchronous, int force)
|
||||
|
||||
// Creates a MIME database entry for one or more applications.
|
||||
status_t
|
||||
create_app_meta_mime(const char *path, int recursive, int synchronous,
|
||||
create_app_meta_mime(const char* path, int recursive, int synchronous,
|
||||
int force)
|
||||
{
|
||||
// Force recursion when given a NULL path
|
||||
@ -112,7 +108,7 @@ create_app_meta_mime(const char *path, int recursive, int synchronous,
|
||||
|
||||
// Retrieves an icon associated with a given device.
|
||||
status_t
|
||||
get_device_icon(const char *device, void *icon, int32 size)
|
||||
get_device_icon(const char* device, void* icon, int32 size)
|
||||
{
|
||||
if (device == NULL || icon == NULL
|
||||
|| (size != B_LARGE_ICON && size != B_MINI_ICON))
|
||||
@ -169,7 +165,7 @@ get_device_icon(const char *device, void *icon, int32 size)
|
||||
|
||||
// Retrieves an icon associated with a given device.
|
||||
status_t
|
||||
get_device_icon(const char *device, BBitmap *icon, icon_size which)
|
||||
get_device_icon(const char* device, BBitmap* icon, icon_size which)
|
||||
{
|
||||
// check parameters
|
||||
if (device == NULL || icon == NULL)
|
||||
@ -225,7 +221,7 @@ get_device_icon(const char *device, BBitmap *icon, icon_size which)
|
||||
|
||||
|
||||
status_t
|
||||
get_device_icon(const char *device, uint8** _data, size_t* _size,
|
||||
get_device_icon(const char* device, uint8** _data, size_t* _size,
|
||||
type_code* _type)
|
||||
{
|
||||
if (device == NULL || _data == NULL || _size == NULL || _type == NULL)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011, Haiku Inc.
|
||||
* Copyright 2002-2011 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -33,8 +33,9 @@
|
||||
|
||||
|
||||
node_ref::node_ref()
|
||||
: device((dev_t)-1),
|
||||
node((ino_t)-1)
|
||||
:
|
||||
device((dev_t)-1),
|
||||
node((ino_t)-1)
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,25 +48,26 @@ node_ref::node_ref(dev_t device, ino_t node)
|
||||
}
|
||||
|
||||
|
||||
node_ref::node_ref(const node_ref &ref)
|
||||
: device((dev_t)-1),
|
||||
node((ino_t)-1)
|
||||
node_ref::node_ref(const node_ref& other)
|
||||
:
|
||||
device((dev_t)-1),
|
||||
node((ino_t)-1)
|
||||
{
|
||||
*this = ref;
|
||||
*this = other;
|
||||
}
|
||||
|
||||
// ==
|
||||
|
||||
bool
|
||||
node_ref::operator==(const node_ref &ref) const
|
||||
node_ref::operator==(const node_ref& other) const
|
||||
{
|
||||
return (device == ref.device && node == ref.node);
|
||||
return (device == other.device && node == other.node);
|
||||
}
|
||||
|
||||
// !=
|
||||
|
||||
bool
|
||||
node_ref::operator!=(const node_ref &ref) const
|
||||
node_ref::operator!=(const node_ref& other) const
|
||||
{
|
||||
return !(*this == ref);
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
|
||||
@ -74,16 +76,16 @@ node_ref::operator<(const node_ref& other) const
|
||||
{
|
||||
if (this->device != other.device)
|
||||
return this->device < other.device;
|
||||
|
||||
return this->node < other.node;
|
||||
}
|
||||
|
||||
|
||||
// =
|
||||
node_ref&
|
||||
node_ref::operator=(const node_ref &ref)
|
||||
node_ref::operator=(const node_ref& other)
|
||||
{
|
||||
device = ref.device;
|
||||
node = ref.node;
|
||||
device = other.device;
|
||||
node = other.node;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -92,53 +94,59 @@ node_ref::operator=(const node_ref &ref)
|
||||
|
||||
|
||||
BNode::BNode()
|
||||
: fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
:
|
||||
fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BNode::BNode(const entry_ref *ref)
|
||||
: fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
BNode::BNode(const entry_ref* ref)
|
||||
:
|
||||
fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
{
|
||||
SetTo(ref);
|
||||
}
|
||||
|
||||
|
||||
BNode::BNode(const BEntry *entry)
|
||||
: fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
BNode::BNode(const BEntry* entry)
|
||||
:
|
||||
fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
{
|
||||
SetTo(entry);
|
||||
}
|
||||
|
||||
|
||||
BNode::BNode(const char *path)
|
||||
: fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
BNode::BNode(const char* path)
|
||||
:
|
||||
fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
{
|
||||
SetTo(path);
|
||||
}
|
||||
|
||||
|
||||
BNode::BNode(const BDirectory *dir, const char *path)
|
||||
: fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
BNode::BNode(const BDirectory* dir, const char* path)
|
||||
:
|
||||
fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
{
|
||||
SetTo(dir, path);
|
||||
}
|
||||
|
||||
|
||||
BNode::BNode(const BNode &node)
|
||||
: fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
BNode::BNode(const BNode& node)
|
||||
:
|
||||
fFd(-1),
|
||||
fAttrFd(-1),
|
||||
fCStatus(B_NO_INIT)
|
||||
{
|
||||
*this = node;
|
||||
}
|
||||
@ -158,37 +166,40 @@ BNode::InitCheck() const
|
||||
|
||||
|
||||
status_t
|
||||
BNode::SetTo(const entry_ref *ref)
|
||||
BNode::SetTo(const entry_ref* ref)
|
||||
{
|
||||
return _SetTo(ref, false);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::SetTo(const BEntry *entry)
|
||||
BNode::SetTo(const BEntry* entry)
|
||||
{
|
||||
if (!entry) {
|
||||
if (entry == NULL) {
|
||||
Unset();
|
||||
return (fCStatus = B_BAD_VALUE);
|
||||
}
|
||||
|
||||
return _SetTo(entry->fDirFd, entry->fName, false);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::SetTo(const char *path)
|
||||
BNode::SetTo(const char* path)
|
||||
{
|
||||
return _SetTo(-1, path, false);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::SetTo(const BDirectory *dir, const char *path)
|
||||
BNode::SetTo(const BDirectory* dir, const char* path)
|
||||
{
|
||||
if (!dir || !path || BPrivate::Storage::is_absolute_path(path)) {
|
||||
if (dir == NULL || path == NULL
|
||||
|| BPrivate::Storage::is_absolute_path(path)) {
|
||||
Unset();
|
||||
return (fCStatus = B_BAD_VALUE);
|
||||
}
|
||||
|
||||
return _SetTo(dir->fDirFd, path, false);
|
||||
}
|
||||
|
||||
@ -206,6 +217,7 @@ BNode::Lock()
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return fCStatus;
|
||||
|
||||
return _kern_lock_node(fFd);
|
||||
}
|
||||
|
||||
@ -215,6 +227,7 @@ BNode::Unlock()
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return fCStatus;
|
||||
|
||||
return _kern_unlock_node(fFd);
|
||||
}
|
||||
|
||||
@ -227,56 +240,61 @@ BNode::Sync()
|
||||
|
||||
|
||||
ssize_t
|
||||
BNode::WriteAttr(const char *attr, type_code type, off_t offset,
|
||||
const void *buffer, size_t len)
|
||||
BNode::WriteAttr(const char* attr, type_code type, off_t offset,
|
||||
const void* buffer, size_t length)
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
if (!attr || !buffer)
|
||||
|
||||
if (attr == NULL || buffer == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
ssize_t result = fs_write_attr(fFd, attr, type, offset, buffer, len);
|
||||
ssize_t result = fs_write_attr(fFd, attr, type, offset, buffer, length);
|
||||
|
||||
return result < 0 ? errno : result;
|
||||
}
|
||||
|
||||
|
||||
ssize_t
|
||||
BNode::ReadAttr(const char *attr, type_code type, off_t offset,
|
||||
void *buffer, size_t len) const
|
||||
BNode::ReadAttr(const char* attr, type_code type, off_t offset,
|
||||
void* buffer, size_t length) const
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
if (!attr || !buffer)
|
||||
|
||||
if (attr == NULL || buffer == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
ssize_t result = fs_read_attr(fFd, attr, type, offset, buffer, len );
|
||||
ssize_t result = fs_read_attr(fFd, attr, type, offset, buffer, length);
|
||||
|
||||
return result == -1 ? errno : result;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::RemoveAttr(const char *name)
|
||||
BNode::RemoveAttr(const char* name)
|
||||
{
|
||||
return fCStatus != B_OK ? B_FILE_ERROR : _kern_remove_attr(fFd, name);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::RenameAttr(const char *oldname, const char *newname)
|
||||
BNode::RenameAttr(const char* oldName, const char* newName)
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
|
||||
return _kern_rename_attr(fFd, oldname, fFd, newname);
|
||||
return _kern_rename_attr(fFd, oldName, fFd, newName);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::GetAttrInfo(const char *name, struct attr_info *info) const
|
||||
BNode::GetAttrInfo(const char* name, struct attr_info* info) const
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
if (!name || !info)
|
||||
|
||||
if (name == NULL || info == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
return fs_stat_attr(fFd, name, info) < 0 ? errno : B_OK ;
|
||||
@ -284,13 +302,16 @@ BNode::GetAttrInfo(const char *name, struct attr_info *info) const
|
||||
|
||||
|
||||
status_t
|
||||
BNode::GetNextAttrName(char *buffer)
|
||||
BNode::GetNextAttrName(char* buffer)
|
||||
{
|
||||
// We're allowed to assume buffer is at least
|
||||
// B_ATTR_NAME_LENGTH chars long, but NULLs
|
||||
// are not acceptable.
|
||||
|
||||
// BeOS R5 crashed when passed NULL
|
||||
if (buffer == NULL)
|
||||
return B_BAD_VALUE; // /new R5 crashed when passed NULL
|
||||
return B_BAD_VALUE;
|
||||
|
||||
if (InitAttrDir() != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
|
||||
@ -298,9 +319,12 @@ BNode::GetNextAttrName(char *buffer)
|
||||
ssize_t result = _kern_read_dir(fAttrFd, &entry, sizeof(entry), 1);
|
||||
if (result < 0)
|
||||
return result;
|
||||
|
||||
if (result == 0)
|
||||
return B_ENTRY_NOT_FOUND;
|
||||
|
||||
strlcpy(buffer, entry.d_name, B_ATTR_NAME_LENGTH);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@ -316,24 +340,25 @@ BNode::RewindAttrs()
|
||||
|
||||
|
||||
status_t
|
||||
BNode::WriteAttrString(const char *name, const BString *data)
|
||||
BNode::WriteAttrString(const char* name, const BString* data)
|
||||
{
|
||||
status_t error = (!name || !data) ? B_BAD_VALUE : B_OK;
|
||||
if (error == B_OK) {
|
||||
int32 len = data->Length() + 1;
|
||||
int32 length = data->Length() + 1;
|
||||
ssize_t sizeWritten = WriteAttr(name, B_STRING_TYPE, 0, data->String(),
|
||||
len);
|
||||
if (sizeWritten != len)
|
||||
length);
|
||||
if (sizeWritten != length)
|
||||
error = sizeWritten;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::ReadAttrString(const char *name, BString *result) const
|
||||
BNode::ReadAttrString(const char* name, BString* result) const
|
||||
{
|
||||
if (!name || !result)
|
||||
if (name == NULL || result == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
attr_info info;
|
||||
@ -344,8 +369,8 @@ BNode::ReadAttrString(const char *name, BString *result) const
|
||||
return error;
|
||||
|
||||
// Lock the string's buffer so we can meddle with it
|
||||
char *data = result->LockBuffer(info.size + 1);
|
||||
if (!data)
|
||||
char* data = result->LockBuffer(info.size + 1);
|
||||
if (data == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
// Read the attribute
|
||||
@ -353,7 +378,8 @@ BNode::ReadAttrString(const char *name, BString *result) const
|
||||
// Check for failure
|
||||
if (bytes < 0) {
|
||||
error = bytes;
|
||||
bytes = 0; // In this instance, we simply clear the string
|
||||
bytes = 0;
|
||||
// In this instance, we simply clear the string
|
||||
} else
|
||||
error = B_OK;
|
||||
|
||||
@ -361,12 +387,13 @@ BNode::ReadAttrString(const char *name, BString *result) const
|
||||
// possible to read and write non-NULL-terminated strings)
|
||||
data[bytes] = 0;
|
||||
result->UnlockBuffer();
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
BNode&
|
||||
BNode::operator=(const BNode &node)
|
||||
BNode::operator=(const BNode& node)
|
||||
{
|
||||
// No need to do any assignment if already equal
|
||||
if (*this == node)
|
||||
@ -378,30 +405,35 @@ BNode::operator=(const BNode &node)
|
||||
// is not declared to be const (which IMO is retarded).
|
||||
fFd = _kern_dup(node.fFd);
|
||||
fCStatus = (fFd < 0) ? B_NO_INIT : B_OK ;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BNode::operator==(const BNode &node) const
|
||||
BNode::operator==(const BNode& node) const
|
||||
{
|
||||
if (fCStatus == B_NO_INIT && node.InitCheck() == B_NO_INIT)
|
||||
return true;
|
||||
|
||||
if (fCStatus == B_OK && node.InitCheck() == B_OK) {
|
||||
// compare the node_refs
|
||||
node_ref ref1, ref2;
|
||||
if (GetNodeRef(&ref1) != B_OK)
|
||||
return false;
|
||||
|
||||
if (node.GetNodeRef(&ref2) != B_OK)
|
||||
return false;
|
||||
|
||||
return (ref1 == ref2);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BNode::operator!=(const BNode &node) const
|
||||
BNode::operator!=(const BNode& node) const
|
||||
{
|
||||
return !(*this == node);
|
||||
}
|
||||
@ -411,7 +443,9 @@ int
|
||||
BNode::Dup()
|
||||
{
|
||||
int fd = _kern_dup(fFd);
|
||||
return (fd >= 0 ? fd : -1); // comply with R5 return value
|
||||
|
||||
return (fd >= 0 ? fd : -1);
|
||||
// comply with R5 return value
|
||||
}
|
||||
|
||||
|
||||
@ -424,16 +458,40 @@ void BNode::_RudeNode5() { }
|
||||
void BNode::_RudeNode6() { }
|
||||
|
||||
|
||||
/*! Sets the node's file descriptor.
|
||||
|
||||
Used by each implementation (i.e. BNode, BFile, BDirectory, etc.) to set
|
||||
the node's file descriptor. This allows each subclass to use the various
|
||||
file-type specific system calls for opening file descriptors.
|
||||
|
||||
\note This method calls close_fd() to close previously opened FDs. Thus
|
||||
derived classes should take care to first call set_fd() and set
|
||||
class specific resources freed in their close_fd() version
|
||||
thereafter.
|
||||
|
||||
\param fd the file descriptor this BNode should be set to (may be -1).
|
||||
|
||||
\returns \c B_OK if everything went fine, or an error code if something
|
||||
went wrong.
|
||||
*/
|
||||
status_t
|
||||
BNode::set_fd(int fd)
|
||||
{
|
||||
if (fFd != -1)
|
||||
close_fd();
|
||||
|
||||
fFd = fd;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
/*! Closes the node's file descriptor(s).
|
||||
|
||||
To be implemented by subclasses to close the file descriptor using the
|
||||
proper system call for the given file-type. This implementation calls
|
||||
_kern_close(fFd) and also _kern_close(fAttrDir) if necessary.
|
||||
*/
|
||||
void
|
||||
BNode::close_fd()
|
||||
{
|
||||
@ -448,6 +506,13 @@ BNode::close_fd()
|
||||
}
|
||||
|
||||
|
||||
/*! Sets the BNode's status.
|
||||
|
||||
To be used by derived classes instead of accessing the BNode's private
|
||||
\c fCStatus member directly.
|
||||
|
||||
\param newStatus the new value for the status variable.
|
||||
*/
|
||||
void
|
||||
BNode::set_status(status_t newStatus)
|
||||
{
|
||||
@ -455,10 +520,36 @@ BNode::set_status(status_t newStatus)
|
||||
}
|
||||
|
||||
|
||||
/*! Initializes the BNode's file descriptor to the node referred to
|
||||
by the given FD and path combo.
|
||||
|
||||
\a path must either be \c NULL, an absolute or a relative path.
|
||||
In the first case, \a fd must not be \c NULL; the node it refers to will
|
||||
be opened. If absolute, \a fd is ignored. If relative and \a fd is >= 0,
|
||||
it will be reckoned off the directory identified by \a fd, otherwise off
|
||||
the current working directory.
|
||||
|
||||
The method will first try to open the node with read and write permission.
|
||||
If that fails due to a read-only FS or because the user has no write
|
||||
permission for the node, it will re-try opening the node read-only.
|
||||
|
||||
The \a fCStatus member will be set to the return value of this method.
|
||||
|
||||
\param fd Either a directory FD or a value < 0. In the latter case \a path
|
||||
must be specified.
|
||||
\param path Either \a NULL in which case \a fd must be given, absolute, or
|
||||
relative to the directory specified by \a fd (if given) or to the
|
||||
current working directory.
|
||||
\param traverse If the node identified by \a fd and \a path is a symlink
|
||||
and \a traverse is \c true, the symlink will be resolved recursively.
|
||||
|
||||
\returns \c B_OK if everything went fine, or an error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
BNode::_SetTo(int fd, const char *path, bool traverse)
|
||||
BNode::_SetTo(int fd, const char* path, bool traverse)
|
||||
{
|
||||
Unset();
|
||||
|
||||
status_t error = (fd >= 0 || path ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
|
||||
@ -470,16 +561,33 @@ BNode::_SetTo(int fd, const char *path, bool traverse)
|
||||
if (fFd < 0)
|
||||
error = fFd;
|
||||
}
|
||||
|
||||
return fCStatus = error;
|
||||
}
|
||||
|
||||
|
||||
/*! Initializes the BNode's file descriptor to the node referred to
|
||||
by the given entry_ref.
|
||||
|
||||
The method will first try to open the node with read and write permission.
|
||||
If that fails due to a read-only FS or because the user has no write
|
||||
permission for the node, it will re-try opening the node read-only.
|
||||
|
||||
The \a fCStatus member will be set to the return value of this method.
|
||||
|
||||
\param ref An entry_ref identifying the node to be opened.
|
||||
\param traverse If the node identified by \a ref is a symlink and
|
||||
\a traverse is \c true, the symlink will be resolved recursively.
|
||||
|
||||
\returns \c B_OK if everything went fine, or an error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
BNode::_SetTo(const entry_ref *ref, bool traverse)
|
||||
BNode::_SetTo(const entry_ref* ref, bool traverse)
|
||||
{
|
||||
Unset();
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK) {
|
||||
|
||||
status_t result = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (result == B_OK) {
|
||||
int traverseFlag = (traverse ? 0 : O_NOTRAVERSE);
|
||||
fFd = _kern_open_entry_ref(ref->device, ref->directory, ref->name,
|
||||
O_RDWR | O_CLOEXEC | traverseFlag, 0);
|
||||
@ -489,23 +597,41 @@ BNode::_SetTo(const entry_ref *ref, bool traverse)
|
||||
O_RDONLY | O_CLOEXEC | traverseFlag, 0);
|
||||
}
|
||||
if (fFd < 0)
|
||||
error = fFd;
|
||||
result = fFd;
|
||||
}
|
||||
return fCStatus = error;
|
||||
|
||||
return fCStatus = result;
|
||||
}
|
||||
|
||||
|
||||
/*! Modifies a certain setting for this node based on \a what and the
|
||||
corresponding value in \a st.
|
||||
|
||||
Inherited from and called by BStatable.
|
||||
|
||||
\param st a stat structure containing the value to be set.
|
||||
\param what specifies what setting to be modified.
|
||||
|
||||
\returns \c B_OK if everything went fine, or an error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
BNode::set_stat(struct stat &st, uint32 what)
|
||||
BNode::set_stat(struct stat& stat, uint32 what)
|
||||
{
|
||||
if (fCStatus != B_OK)
|
||||
return B_FILE_ERROR;
|
||||
|
||||
return _kern_write_stat(fFd, NULL, false, &st, sizeof(struct stat),
|
||||
return _kern_write_stat(fFd, NULL, false, &stat, sizeof(struct stat),
|
||||
what);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! Verifies that the BNode has been properly initialized, and then
|
||||
(if necessary) opens the attribute directory on the node's file
|
||||
descriptor, storing it in fAttrDir.
|
||||
|
||||
\returns \c B_OK if everything went fine, or an error code otherwise.
|
||||
*/
|
||||
status_t
|
||||
BNode::InitAttrDir()
|
||||
{
|
||||
@ -517,33 +643,35 @@ BNode::InitAttrDir()
|
||||
// set close on exec flag
|
||||
fcntl(fAttrFd, F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
|
||||
return fCStatus;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::_GetStat(struct stat *st) const
|
||||
BNode::_GetStat(struct stat* stat) const
|
||||
{
|
||||
return fCStatus != B_OK
|
||||
? fCStatus
|
||||
: _kern_read_stat(fFd, NULL, false, st, sizeof(struct stat));
|
||||
: _kern_read_stat(fFd, NULL, false, stat, sizeof(struct stat));
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BNode::_GetStat(struct stat_beos *st) const
|
||||
BNode::_GetStat(struct stat_beos* stat) const
|
||||
{
|
||||
struct stat newStat;
|
||||
status_t error = _GetStat(&newStat);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
convert_to_stat_beos(&newStat, st);
|
||||
convert_to_stat_beos(&newStat, stat);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - symbol versions
|
||||
// #pragma mark - symbol versions
|
||||
|
||||
|
||||
#ifdef HAIKU_TARGET_PLATFORM_LIBBE_TEST
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku Inc.
|
||||
* Copyright 2002-2010 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -24,16 +24,21 @@
|
||||
#include <fs_attr.h>
|
||||
#include <fs_info.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
// attribute names
|
||||
#define NI_BEOS "BEOS"
|
||||
static const char *kNITypeAttribute = NI_BEOS ":TYPE";
|
||||
static const char *kNIPreferredAppAttribute = NI_BEOS ":PREF_APP";
|
||||
static const char *kNIAppHintAttribute = NI_BEOS ":PPATH";
|
||||
static const char *kNIMiniIconAttribute = NI_BEOS ":M:STD_ICON";
|
||||
static const char *kNILargeIconAttribute = NI_BEOS ":L:STD_ICON";
|
||||
static const char *kNIIconAttribute = NI_BEOS ":ICON";
|
||||
static const char* kNITypeAttribute = NI_BEOS ":TYPE";
|
||||
static const char* kNIPreferredAppAttribute = NI_BEOS ":PREF_APP";
|
||||
static const char* kNIAppHintAttribute = NI_BEOS ":PPATH";
|
||||
static const char* kNIMiniIconAttribute = NI_BEOS ":M:STD_ICON";
|
||||
static const char* kNILargeIconAttribute = NI_BEOS ":L:STD_ICON";
|
||||
static const char* kNIIconAttribute = NI_BEOS ":ICON";
|
||||
|
||||
|
||||
// #pragma mark - BNodeInfo
|
||||
|
||||
|
||||
BNodeInfo::BNodeInfo()
|
||||
@ -44,7 +49,7 @@ BNodeInfo::BNodeInfo()
|
||||
}
|
||||
|
||||
|
||||
BNodeInfo::BNodeInfo(BNode *node)
|
||||
BNodeInfo::BNodeInfo(BNode* node)
|
||||
:
|
||||
fNode(NULL),
|
||||
fCStatus(B_NO_INIT)
|
||||
@ -60,7 +65,7 @@ BNodeInfo::~BNodeInfo()
|
||||
|
||||
// Initializes the BNodeInfo to the supplied node.
|
||||
status_t
|
||||
BNodeInfo::SetTo(BNode *node)
|
||||
BNodeInfo::SetTo(BNode* node)
|
||||
{
|
||||
fNode = NULL;
|
||||
// check parameter
|
||||
@ -82,166 +87,83 @@ BNodeInfo::InitCheck() const
|
||||
|
||||
// Writes the MIME type of the node into type.
|
||||
status_t
|
||||
BNodeInfo::GetType(char *type) const
|
||||
BNodeInfo::GetType(char* type) const
|
||||
{
|
||||
// check parameter and initialization
|
||||
status_t error = (type ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
status_t result = (type ? B_OK : B_BAD_VALUE);
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
// get the attribute info and check type and length of the attr contents
|
||||
attr_info attrInfo;
|
||||
if (error == B_OK)
|
||||
error = fNode->GetAttrInfo(kNITypeAttribute, &attrInfo);
|
||||
if (error == B_OK && attrInfo.type != B_MIME_STRING_TYPE)
|
||||
error = B_BAD_TYPE;
|
||||
if (error == B_OK && attrInfo.size > B_MIME_TYPE_LENGTH)
|
||||
error = B_BAD_DATA;
|
||||
if (result == B_OK)
|
||||
result = fNode->GetAttrInfo(kNITypeAttribute, &attrInfo);
|
||||
if (result == B_OK && attrInfo.type != B_MIME_STRING_TYPE)
|
||||
result = B_BAD_TYPE;
|
||||
if (result == B_OK && attrInfo.size > B_MIME_TYPE_LENGTH)
|
||||
result = B_BAD_DATA;
|
||||
|
||||
// read the data
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
ssize_t read = fNode->ReadAttr(kNITypeAttribute, attrInfo.type, 0,
|
||||
type, attrInfo.size);
|
||||
if (read < 0)
|
||||
error = read;
|
||||
result = read;
|
||||
else if (read != attrInfo.size)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
// attribute strings doesn't have to be null terminated
|
||||
type[min_c(attrInfo.size, B_MIME_TYPE_LENGTH - 1)] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Sets the MIME type of the node. If type is NULL the BEOS:TYPE attribute is
|
||||
// removed instead.
|
||||
status_t
|
||||
BNodeInfo::SetType(const char *type)
|
||||
BNodeInfo::SetType(const char* type)
|
||||
{
|
||||
// check parameter and initialization
|
||||
status_t error = B_OK;
|
||||
if (error == B_OK && type && strlen(type) >= B_MIME_TYPE_LENGTH)
|
||||
error = B_BAD_VALUE;
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
status_t result = B_OK;
|
||||
if (result == B_OK && type && strlen(type) >= B_MIME_TYPE_LENGTH)
|
||||
result = B_BAD_VALUE;
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
|
||||
// write/remove the attribute
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
if (type) {
|
||||
size_t toWrite = strlen(type) + 1;
|
||||
ssize_t written = fNode->WriteAttr(kNITypeAttribute,
|
||||
B_MIME_STRING_TYPE, 0, type,
|
||||
toWrite);
|
||||
if (written < 0)
|
||||
error = written;
|
||||
result = written;
|
||||
else if (written != (ssize_t)toWrite)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
} else
|
||||
error = fNode->RemoveAttr(kNITypeAttribute);
|
||||
result = fNode->RemoveAttr(kNITypeAttribute);
|
||||
}
|
||||
return error;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Gets the icon of the node.
|
||||
status_t
|
||||
BNodeInfo::GetIcon(BBitmap *icon, icon_size k) const
|
||||
BNodeInfo::GetIcon(BBitmap* icon, icon_size which) const
|
||||
{
|
||||
const char* iconAttribute = kNIIconAttribute;
|
||||
const char* miniIconAttribute = kNIMiniIconAttribute;
|
||||
const char* largeIconAttribute = kNILargeIconAttribute;
|
||||
|
||||
return BIconUtils::GetIcon(fNode, iconAttribute, miniIconAttribute,
|
||||
largeIconAttribute, k, icon);
|
||||
|
||||
// status_t error = B_OK;
|
||||
// // set some icon size related variables
|
||||
// const char *attribute = NULL;
|
||||
// BRect bounds;
|
||||
// uint32 attrType = 0;
|
||||
// size_t attrSize = 0;
|
||||
// switch (k) {
|
||||
// case B_MINI_ICON:
|
||||
// attribute = kNIMiniIconAttribute;
|
||||
// bounds.Set(0, 0, 15, 15);
|
||||
// attrType = B_MINI_ICON_TYPE;
|
||||
// attrSize = 16 * 16;
|
||||
// break;
|
||||
// case B_LARGE_ICON:
|
||||
// attribute = kNILargeIconAttribute;
|
||||
// bounds.Set(0, 0, 31, 31);
|
||||
// attrType = B_LARGE_ICON_TYPE;
|
||||
// attrSize = 32 * 32;
|
||||
// break;
|
||||
// default:
|
||||
// error = B_BAD_VALUE;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// // check parameter and initialization
|
||||
// if (error == B_OK
|
||||
// && (!icon || icon->InitCheck() != B_OK || icon->Bounds() != bounds)) {
|
||||
// error = B_BAD_VALUE;
|
||||
// }
|
||||
// if (error == B_OK && InitCheck() != B_OK)
|
||||
// error = B_NO_INIT;
|
||||
//
|
||||
// // get the attribute info and check type and size of the attr contents
|
||||
// attr_info attrInfo;
|
||||
// if (error == B_OK)
|
||||
// error = fNode->GetAttrInfo(attribute, &attrInfo);
|
||||
// if (error == B_OK && attrInfo.type != attrType)
|
||||
// error = B_BAD_TYPE;
|
||||
// if (error == B_OK && attrInfo.size != attrSize)
|
||||
// error = B_BAD_DATA;
|
||||
//
|
||||
// // read the attribute
|
||||
// if (error == B_OK) {
|
||||
// bool otherColorSpace = (icon->ColorSpace() != B_CMAP8);
|
||||
// char *buffer = NULL;
|
||||
// ssize_t read;
|
||||
// if (otherColorSpace) {
|
||||
// // other color space than stored in attribute
|
||||
// buffer = new(nothrow) char[attrSize];
|
||||
// if (!buffer)
|
||||
// error = B_NO_MEMORY;
|
||||
// if (error == B_OK) {
|
||||
// read = fNode->ReadAttr(attribute, attrType, 0, buffer,
|
||||
// attrSize);
|
||||
// }
|
||||
// } else {
|
||||
// read = fNode->ReadAttr(attribute, attrType, 0, icon->Bits(),
|
||||
// attrSize);
|
||||
// }
|
||||
// if (error == B_OK) {
|
||||
// if (read < 0)
|
||||
// error = read;
|
||||
// else if (read != attrInfo.size)
|
||||
// error = B_ERROR;
|
||||
// }
|
||||
// if (otherColorSpace) {
|
||||
// // other color space than stored in attribute
|
||||
// if (error == B_OK) {
|
||||
// error = icon->ImportBits(buffer, attrSize, B_ANY_BYTES_PER_ROW,
|
||||
// 0, B_CMAP8);
|
||||
// }
|
||||
// delete[] buffer;
|
||||
// }
|
||||
// }
|
||||
// return error;
|
||||
}
|
||||
|
||||
|
||||
// Sets the icon of the node. If icon is NULL, the attribute is removed
|
||||
// instead.
|
||||
status_t
|
||||
BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
|
||||
{
|
||||
status_t error = B_OK;
|
||||
largeIconAttribute, which, icon);
|
||||
#if 0
|
||||
status_t result = B_OK;
|
||||
// set some icon size related variables
|
||||
const char *attribute = NULL;
|
||||
const char* attribute = NULL;
|
||||
BRect bounds;
|
||||
uint32 attrType = 0;
|
||||
size_t attrSize = 0;
|
||||
@ -259,46 +181,142 @@ BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
|
||||
attrSize = 32 * 32;
|
||||
break;
|
||||
default:
|
||||
error = B_BAD_VALUE;
|
||||
result = B_BAD_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
// check parameter and initialization
|
||||
if (error == B_OK && icon
|
||||
&& (icon->InitCheck() != B_OK || icon->Bounds() != bounds)) {
|
||||
error = B_BAD_VALUE;
|
||||
if (result == B_OK
|
||||
&& (icon == NULL || icon->InitCheck() != B_OK
|
||||
|| icon->Bounds() != bounds)) {
|
||||
result = B_BAD_VALUE;
|
||||
}
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
|
||||
// get the attribute info and check type and size of the attr contents
|
||||
attr_info attrInfo;
|
||||
if (result == B_OK)
|
||||
result = fNode->GetAttrInfo(attribute, &attrInfo);
|
||||
|
||||
if (result == B_OK && attrInfo.type != attrType)
|
||||
result = B_BAD_TYPE;
|
||||
|
||||
if (result == B_OK && attrInfo.size != attrSize)
|
||||
result = B_BAD_DATA;
|
||||
|
||||
// read the attribute
|
||||
if (result == B_OK) {
|
||||
bool otherColorSpace = (icon->ColorSpace() != B_CMAP8);
|
||||
char *buffer = NULL;
|
||||
ssize_t read;
|
||||
if (otherColorSpace) {
|
||||
// other color space than stored in attribute
|
||||
buffer = new(nothrow) char[attrSize];
|
||||
if (!buffer)
|
||||
result = B_NO_MEMORY;
|
||||
if (result == B_OK) {
|
||||
read = fNode->ReadAttr(attribute, attrType, 0, buffer,
|
||||
attrSize);
|
||||
}
|
||||
} else {
|
||||
read = fNode->ReadAttr(attribute, attrType, 0, icon->Bits(),
|
||||
attrSize);
|
||||
}
|
||||
if (result == B_OK) {
|
||||
if (read < 0)
|
||||
result = read;
|
||||
else if (read != attrInfo.size)
|
||||
result = B_ERROR;
|
||||
}
|
||||
if (otherColorSpace) {
|
||||
// other color space than stored in attribute
|
||||
if (result == B_OK) {
|
||||
result = icon->ImportBits(buffer, attrSize, B_ANY_BYTES_PER_ROW,
|
||||
0, B_CMAP8);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Sets the icon of the node. If icon is NULL, the attribute is removed
|
||||
// instead.
|
||||
status_t
|
||||
BNodeInfo::SetIcon(const BBitmap* icon, icon_size which)
|
||||
{
|
||||
status_t result = B_OK;
|
||||
|
||||
// set some icon size related variables
|
||||
const char* attribute = NULL;
|
||||
BRect bounds;
|
||||
uint32 attrType = 0;
|
||||
size_t attrSize = 0;
|
||||
|
||||
switch (which) {
|
||||
case B_MINI_ICON:
|
||||
attribute = kNIMiniIconAttribute;
|
||||
bounds.Set(0, 0, 15, 15);
|
||||
attrType = B_MINI_ICON_TYPE;
|
||||
attrSize = 16 * 16;
|
||||
break;
|
||||
|
||||
case B_LARGE_ICON:
|
||||
attribute = kNILargeIconAttribute;
|
||||
bounds.Set(0, 0, 31, 31);
|
||||
attrType = B_LARGE_ICON_TYPE;
|
||||
attrSize = 32 * 32;
|
||||
break;
|
||||
|
||||
default:
|
||||
result = B_BAD_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
// check parameter and initialization
|
||||
if (result == B_OK && icon != NULL
|
||||
&& (icon->InitCheck() != B_OK || icon->Bounds() != bounds)) {
|
||||
result = B_BAD_VALUE;
|
||||
}
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
|
||||
// write/remove the attribute
|
||||
if (error == B_OK) {
|
||||
if (icon) {
|
||||
if (result == B_OK) {
|
||||
if (icon != NULL) {
|
||||
bool otherColorSpace = (icon->ColorSpace() != B_CMAP8);
|
||||
ssize_t written = 0;
|
||||
if (otherColorSpace) {
|
||||
BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_CMAP8);
|
||||
error = bitmap.InitCheck();
|
||||
if (error == B_OK)
|
||||
error = bitmap.ImportBits(icon);
|
||||
if (error == B_OK) {
|
||||
result = bitmap.InitCheck();
|
||||
if (result == B_OK)
|
||||
result = bitmap.ImportBits(icon);
|
||||
|
||||
if (result == B_OK) {
|
||||
written = fNode->WriteAttr(attribute, attrType, 0,
|
||||
bitmap.Bits(), attrSize);
|
||||
bitmap.Bits(), attrSize);
|
||||
}
|
||||
} else {
|
||||
written = fNode->WriteAttr(attribute, attrType, 0,
|
||||
icon->Bits(), attrSize);
|
||||
icon->Bits(), attrSize);
|
||||
}
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
if (written < 0)
|
||||
error = written;
|
||||
result = written;
|
||||
else if (written != (ssize_t)attrSize)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
}
|
||||
} else // no icon given => remove
|
||||
error = fNode->RemoveAttr(attribute);
|
||||
} else {
|
||||
// no icon given => remove
|
||||
result = fNode->RemoveAttr(attribute);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -307,7 +325,7 @@ status_t
|
||||
BNodeInfo::GetIcon(uint8** data, size_t* size, type_code* type) const
|
||||
{
|
||||
// check params
|
||||
if (!data || !size || !type)
|
||||
if (data == NULL || size == NULL || type == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// check initialization
|
||||
@ -353,183 +371,190 @@ BNodeInfo::SetIcon(const uint8* data, size_t size)
|
||||
if (InitCheck() != B_OK)
|
||||
return B_NO_INIT;
|
||||
|
||||
status_t error = B_OK;
|
||||
status_t result = B_OK;
|
||||
|
||||
// write/remove the attribute
|
||||
if (data && size > 0) {
|
||||
ssize_t written = fNode->WriteAttr(kNIIconAttribute,
|
||||
B_VECTOR_ICON_TYPE,
|
||||
0, data, size);
|
||||
B_VECTOR_ICON_TYPE, 0, data, size);
|
||||
if (written < 0)
|
||||
error = (status_t)written;
|
||||
result = (status_t)written;
|
||||
else if (written != (ssize_t)size)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
} else {
|
||||
// no icon given => remove
|
||||
error = fNode->RemoveAttr(kNIIconAttribute);
|
||||
result = fNode->RemoveAttr(kNIIconAttribute);
|
||||
}
|
||||
|
||||
return error;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Gets the preferred application of the node.
|
||||
status_t
|
||||
BNodeInfo::GetPreferredApp(char *signature, app_verb verb) const
|
||||
BNodeInfo::GetPreferredApp(char* signature, app_verb verb) const
|
||||
{
|
||||
// check parameter and initialization
|
||||
status_t error = (signature && verb == B_OPEN ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
status_t result = (signature && verb == B_OPEN ? B_OK : B_BAD_VALUE);
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
|
||||
// get the attribute info and check type and length of the attr contents
|
||||
attr_info attrInfo;
|
||||
if (error == B_OK)
|
||||
error = fNode->GetAttrInfo(kNIPreferredAppAttribute, &attrInfo);
|
||||
if (error == B_OK && attrInfo.type != B_MIME_STRING_TYPE)
|
||||
error = B_BAD_TYPE;
|
||||
if (error == B_OK && attrInfo.size > B_MIME_TYPE_LENGTH)
|
||||
error = B_BAD_DATA;
|
||||
if (result == B_OK)
|
||||
result = fNode->GetAttrInfo(kNIPreferredAppAttribute, &attrInfo);
|
||||
|
||||
if (result == B_OK && attrInfo.type != B_MIME_STRING_TYPE)
|
||||
result = B_BAD_TYPE;
|
||||
|
||||
if (result == B_OK && attrInfo.size > B_MIME_TYPE_LENGTH)
|
||||
result = B_BAD_DATA;
|
||||
|
||||
// read the data
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
ssize_t read = fNode->ReadAttr(kNIPreferredAppAttribute, attrInfo.type,
|
||||
0, signature, attrInfo.size);
|
||||
0, signature, attrInfo.size);
|
||||
if (read < 0)
|
||||
error = read;
|
||||
result = read;
|
||||
else if (read != attrInfo.size)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
// attribute strings doesn't have to be null terminated
|
||||
signature[min_c(attrInfo.size, B_MIME_TYPE_LENGTH - 1)] = '\0';
|
||||
}
|
||||
}
|
||||
return error;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Sets the preferred application of the node. If signature is NULL, the
|
||||
// "BEOS:PREF_APP" attribute is removed instead.
|
||||
status_t
|
||||
BNodeInfo::SetPreferredApp(const char *signature, app_verb verb)
|
||||
BNodeInfo::SetPreferredApp(const char* signature, app_verb verb)
|
||||
{
|
||||
// check parameters and initialization
|
||||
status_t error = (verb == B_OPEN ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK && signature && strlen(signature) >= B_MIME_TYPE_LENGTH)
|
||||
error = B_BAD_VALUE;
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
status_t result = (verb == B_OPEN ? B_OK : B_BAD_VALUE);
|
||||
if (result == B_OK && signature && strlen(signature) >= B_MIME_TYPE_LENGTH)
|
||||
result = B_BAD_VALUE;
|
||||
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
|
||||
// write/remove the attribute
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
if (signature) {
|
||||
size_t toWrite = strlen(signature) + 1;
|
||||
ssize_t written = fNode->WriteAttr(kNIPreferredAppAttribute,
|
||||
B_MIME_STRING_TYPE, 0,
|
||||
signature, toWrite);
|
||||
B_MIME_STRING_TYPE, 0, signature, toWrite);
|
||||
if (written < 0)
|
||||
error = written;
|
||||
result = written;
|
||||
else if (written != (ssize_t)toWrite)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
} else
|
||||
error = fNode->RemoveAttr(kNIPreferredAppAttribute);
|
||||
result = fNode->RemoveAttr(kNIPreferredAppAttribute);
|
||||
}
|
||||
return error;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Fills out ref with a pointer to a hint about what application will open
|
||||
// this node.
|
||||
status_t
|
||||
BNodeInfo::GetAppHint(entry_ref *ref) const
|
||||
BNodeInfo::GetAppHint(entry_ref* ref) const
|
||||
{
|
||||
// check parameter and initialization
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
status_t result = (ref ? B_OK : B_BAD_VALUE);
|
||||
if (result == B_OK && InitCheck() != B_OK)
|
||||
result = B_NO_INIT;
|
||||
|
||||
// get the attribute info and check type and length of the attr contents
|
||||
attr_info attrInfo;
|
||||
if (error == B_OK)
|
||||
error = fNode->GetAttrInfo(kNIAppHintAttribute, &attrInfo);
|
||||
if (result == B_OK)
|
||||
result = fNode->GetAttrInfo(kNIAppHintAttribute, &attrInfo);
|
||||
|
||||
// NOTE: The attribute type should be B_STRING_TYPE, but R5 uses
|
||||
// B_MIME_STRING_TYPE.
|
||||
if (error == B_OK && attrInfo.type != B_MIME_STRING_TYPE)
|
||||
error = B_BAD_TYPE;
|
||||
if (error == B_OK && attrInfo.size > B_PATH_NAME_LENGTH)
|
||||
error = B_BAD_DATA;
|
||||
if (result == B_OK && attrInfo.type != B_MIME_STRING_TYPE)
|
||||
result = B_BAD_TYPE;
|
||||
|
||||
if (result == B_OK && attrInfo.size > B_PATH_NAME_LENGTH)
|
||||
result = B_BAD_DATA;
|
||||
|
||||
// read the data
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
char path[B_PATH_NAME_LENGTH];
|
||||
ssize_t read = fNode->ReadAttr(kNIAppHintAttribute, attrInfo.type, 0,
|
||||
path, attrInfo.size);
|
||||
path, attrInfo.size);
|
||||
if (read < 0)
|
||||
error = read;
|
||||
result = read;
|
||||
else if (read != attrInfo.size)
|
||||
error = B_ERROR;
|
||||
result = B_ERROR;
|
||||
|
||||
// get the entry_ref for the path
|
||||
if (error == B_OK) {
|
||||
if (result == B_OK) {
|
||||
// attribute strings doesn't have to be null terminated
|
||||
path[min_c(attrInfo.size, B_PATH_NAME_LENGTH - 1)] = '\0';
|
||||
error = get_ref_for_path(path, ref);
|
||||
result = get_ref_for_path(path, ref);
|
||||
}
|
||||
}
|
||||
return error;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Sets the app hint of the node. If ref is NULL, the "BEOS:PPATH" attribute
|
||||
// is removed instead.
|
||||
status_t
|
||||
BNodeInfo::SetAppHint(const entry_ref *ref)
|
||||
BNodeInfo::SetAppHint(const entry_ref* ref)
|
||||
{
|
||||
// check parameter and initialization
|
||||
status_t error = B_OK;
|
||||
if (error == B_OK && InitCheck() != B_OK)
|
||||
error = B_NO_INIT;
|
||||
if (InitCheck() != B_OK)
|
||||
return B_NO_INIT;
|
||||
|
||||
// write/remove the attribute
|
||||
if (error == B_OK) {
|
||||
if (ref) {
|
||||
BPath path;
|
||||
error = path.SetTo(ref);
|
||||
if (error == B_OK) {
|
||||
size_t toWrite = strlen(path.Path()) + 1;
|
||||
ssize_t written = fNode->WriteAttr(kNIAppHintAttribute,
|
||||
B_MIME_STRING_TYPE, 0,
|
||||
path.Path(), toWrite);
|
||||
if (written < 0)
|
||||
error = written;
|
||||
else if (written != (ssize_t)toWrite)
|
||||
error = B_ERROR;
|
||||
}
|
||||
} else
|
||||
error = fNode->RemoveAttr(kNIAppHintAttribute);
|
||||
}
|
||||
return error;
|
||||
status_t result = B_OK;
|
||||
if (ref != NULL) {
|
||||
// write/remove the attribute
|
||||
BPath path;
|
||||
result = path.SetTo(ref);
|
||||
if (result == B_OK) {
|
||||
size_t toWrite = strlen(path.Path()) + 1;
|
||||
ssize_t written = fNode->WriteAttr(kNIAppHintAttribute,
|
||||
B_MIME_STRING_TYPE, 0, path.Path(), toWrite);
|
||||
if (written < 0)
|
||||
result = written;
|
||||
else if (written != (ssize_t)toWrite)
|
||||
result = B_ERROR;
|
||||
}
|
||||
} else
|
||||
result = fNode->RemoveAttr(kNIAppHintAttribute);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Gets the icon displayed by Tracker for the icon.
|
||||
status_t
|
||||
BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
BNodeInfo::GetTrackerIcon(BBitmap* icon, icon_size which) const
|
||||
{
|
||||
if (!icon)
|
||||
if (icon == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// set some icon size related variables
|
||||
BRect bounds;
|
||||
switch (iconSize) {
|
||||
switch (which) {
|
||||
case B_MINI_ICON:
|
||||
bounds.Set(0, 0, 15, 15);
|
||||
break;
|
||||
|
||||
case B_LARGE_ICON:
|
||||
bounds.Set(0, 0, 31, 31);
|
||||
break;
|
||||
|
||||
default:
|
||||
// error = B_BAD_VALUE;
|
||||
// result = B_BAD_VALUE;
|
||||
// NOTE: added to be less strict and support scaled icons
|
||||
bounds = icon->Bounds();
|
||||
break;
|
||||
@ -543,20 +568,20 @@ BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
return B_NO_INIT;
|
||||
|
||||
// Ask GetIcon() first.
|
||||
if (GetIcon(icon, iconSize) == B_OK)
|
||||
if (GetIcon(icon, which) == B_OK)
|
||||
return B_OK;
|
||||
|
||||
// If not successful, see if the node has a type available at all.
|
||||
// If no type is available, use one of the standard types.
|
||||
status_t error = B_OK;
|
||||
status_t result = B_OK;
|
||||
char mimeString[B_MIME_TYPE_LENGTH];
|
||||
if (GetType(mimeString) != B_OK) {
|
||||
// Get the icon from a mime type...
|
||||
BMimeType type;
|
||||
|
||||
|
||||
struct stat stat;
|
||||
error = fNode->GetStat(&stat);
|
||||
if (error == B_OK) {
|
||||
result = fNode->GetStat(&stat);
|
||||
if (result == B_OK) {
|
||||
// no type available -- get the icon for the appropriate type
|
||||
// (file/dir/etc.)
|
||||
if (S_ISREG(stat.st_mode)) {
|
||||
@ -581,7 +606,7 @@ BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
type.SetTo(B_FILE_MIME_TYPE);
|
||||
}
|
||||
|
||||
return type.GetIcon(icon, iconSize);
|
||||
return type.GetIcon(icon, which);
|
||||
} else {
|
||||
// We know the mimetype of the node.
|
||||
bool success = false;
|
||||
@ -591,7 +616,7 @@ BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
char signature[B_MIME_TYPE_LENGTH];
|
||||
if (GetPreferredApp(signature) == B_OK) {
|
||||
BMimeType type(signature);
|
||||
success = type.GetIconForType(mimeString, icon, iconSize) == B_OK;
|
||||
success = type.GetIconForType(mimeString, icon, which) == B_OK;
|
||||
}
|
||||
|
||||
// ToDo: Confirm Tracker asks preferred app icons before asking
|
||||
@ -604,13 +629,13 @@ BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
// type.
|
||||
if (!success && nodeType.GetPreferredApp(signature) == B_OK) {
|
||||
BMimeType type(signature);
|
||||
success = type.GetIconForType(mimeString, icon, iconSize) == B_OK;
|
||||
success = type.GetIconForType(mimeString, icon, which) == B_OK;
|
||||
}
|
||||
|
||||
// Ask the MIME database whether there is an icon for the node's file
|
||||
// type.
|
||||
if (!success)
|
||||
success = nodeType.GetIcon(icon, iconSize) == B_OK;
|
||||
success = nodeType.GetIcon(icon, which) == B_OK;
|
||||
|
||||
// Get the super type if still no success.
|
||||
BMimeType superType;
|
||||
@ -621,13 +646,13 @@ BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
if (superType.GetPreferredApp(signature) == B_OK) {
|
||||
BMimeType type(signature);
|
||||
success = type.GetIconForType(superType.Type(), icon,
|
||||
iconSize) == B_OK;
|
||||
which) == B_OK;
|
||||
}
|
||||
// Get the icon of the super type itself.
|
||||
if (!success)
|
||||
success = superType.GetIcon(icon, iconSize) == B_OK;
|
||||
success = superType.GetIcon(icon, which) == B_OK;
|
||||
}
|
||||
|
||||
|
||||
if (success)
|
||||
return B_OK;
|
||||
}
|
||||
@ -638,25 +663,26 @@ BNodeInfo::GetTrackerIcon(BBitmap *icon, icon_size iconSize) const
|
||||
|
||||
// Gets the icon displayed by Tracker for the node referred to by ref.
|
||||
status_t
|
||||
BNodeInfo::GetTrackerIcon(const entry_ref *ref, BBitmap *icon, icon_size iconSize)
|
||||
BNodeInfo::GetTrackerIcon(const entry_ref* ref, BBitmap* icon, icon_size which)
|
||||
{
|
||||
// check ref param
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
status_t result = (ref ? B_OK : B_BAD_VALUE);
|
||||
|
||||
// init a BNode
|
||||
BNode node;
|
||||
if (error == B_OK)
|
||||
error = node.SetTo(ref);
|
||||
if (result == B_OK)
|
||||
result = node.SetTo(ref);
|
||||
|
||||
// init a BNodeInfo
|
||||
BNodeInfo nodeInfo;
|
||||
if (error == B_OK)
|
||||
error = nodeInfo.SetTo(&node);
|
||||
if (result == B_OK)
|
||||
result = nodeInfo.SetTo(&node);
|
||||
|
||||
// let the non-static GetTrackerIcon() do the dirty work
|
||||
if (error == B_OK)
|
||||
error = nodeInfo.GetTrackerIcon(icon, iconSize);
|
||||
return error;
|
||||
if (result == B_OK)
|
||||
result = nodeInfo.GetTrackerIcon(icon, which);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -665,7 +691,7 @@ BNodeInfo::GetTrackerIcon(const entry_ref *ref, BBitmap *icon, icon_size iconSiz
|
||||
extern "C"
|
||||
status_t
|
||||
GetTrackerIcon__9BNodeInfoP9entry_refP7BBitmap9icon_size(
|
||||
BNodeInfo *nodeInfo, entry_ref* ref,
|
||||
BNodeInfo* nodeInfo, entry_ref* ref,
|
||||
BBitmap* bitmap, icon_size iconSize)
|
||||
{
|
||||
// NOTE: nodeInfo is ignored - maybe that's wrong!
|
||||
@ -673,27 +699,14 @@ GetTrackerIcon__9BNodeInfoP9entry_refP7BBitmap9icon_size(
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BNodeInfo::_ReservedNodeInfo1()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BNodeInfo::_ReservedNodeInfo2()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BNodeInfo::_ReservedNodeInfo3()
|
||||
{
|
||||
}
|
||||
void BNodeInfo::_ReservedNodeInfo1() {}
|
||||
void BNodeInfo::_ReservedNodeInfo2() {}
|
||||
void BNodeInfo::_ReservedNodeInfo3() {}
|
||||
|
||||
|
||||
// Assignment operator is declared private to prevent it from being created
|
||||
// automatically by the compiler.
|
||||
BNodeInfo &
|
||||
BNodeInfo&
|
||||
BNodeInfo::operator=(const BNodeInfo &nodeInfo)
|
||||
{
|
||||
return *this;
|
||||
@ -707,15 +720,12 @@ BNodeInfo::BNodeInfo(const BNodeInfo &)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
// Private method used by Tracker. This should be moved to the Tracker
|
||||
// source.
|
||||
extern bool
|
||||
CheckNodeIconHintPrivate(const BNode *node, bool checkMiniIconOnly)
|
||||
CheckNodeIconHintPrivate(const BNode* node, bool checkMiniIconOnly)
|
||||
{
|
||||
attr_info info;
|
||||
if (node->GetAttrInfo(kNIMiniIconAttribute, &info) != B_OK && checkMiniIconOnly)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2010, Haiku.
|
||||
* Copyright 2001-2010 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -39,8 +39,8 @@ watch_volume(dev_t volume, uint32 flags, BMessenger target)
|
||||
|
||||
|
||||
status_t
|
||||
watch_volume(dev_t volume, uint32 flags, const BHandler *handler,
|
||||
const BLooper *looper)
|
||||
watch_volume(dev_t volume, uint32 flags, const BHandler* handler,
|
||||
const BLooper* looper)
|
||||
{
|
||||
return watch_volume(volume, flags, BMessenger(handler, looper));
|
||||
}
|
||||
@ -48,7 +48,7 @@ watch_volume(dev_t volume, uint32 flags, const BHandler *handler,
|
||||
|
||||
// Subscribes or unsubscribes a target to node and/or mount watching.
|
||||
status_t
|
||||
watch_node(const node_ref *node, uint32 flags, BMessenger target)
|
||||
watch_node(const node_ref* node, uint32 flags, BMessenger target)
|
||||
{
|
||||
if (!target.IsValid())
|
||||
return B_BAD_VALUE;
|
||||
@ -92,8 +92,8 @@ watch_node(const node_ref *node, uint32 flags, BMessenger target)
|
||||
// Subscribes or unsubscribes a handler or looper to node and/or mount
|
||||
// watching.
|
||||
status_t
|
||||
watch_node(const node_ref *node, uint32 flags, const BHandler *handler,
|
||||
const BLooper *looper)
|
||||
watch_node(const node_ref* node, uint32 flags, const BHandler* handler,
|
||||
const BLooper* looper)
|
||||
{
|
||||
return watch_node(node, flags, BMessenger(handler, looper));
|
||||
}
|
||||
@ -116,7 +116,7 @@ stop_watching(BMessenger target)
|
||||
|
||||
// Unsubscribes a target from node and mount monitoring.
|
||||
status_t
|
||||
stop_watching(const BHandler *handler, const BLooper *looper)
|
||||
stop_watching(const BHandler* handler, const BLooper* looper)
|
||||
{
|
||||
return stop_watching(BMessenger(handler, looper));
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "storage_support.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
@ -424,7 +425,7 @@ BPath::Flatten(void* buffer, ssize_t size) const
|
||||
if (buffer == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// ToDo: Re-implement for performance reasons: Don't call FlattenedSize().
|
||||
// ToDo: Reimplement for performance reasons: Don't call FlattenedSize().
|
||||
ssize_t flattenedSize = FlattenedSize();
|
||||
if (flattenedSize < 0)
|
||||
return flattenedSize;
|
||||
@ -497,7 +498,17 @@ void BPath::_WarPath2() {}
|
||||
void BPath::_WarPath3() {}
|
||||
|
||||
|
||||
// Sets the supplied path.
|
||||
/*! Sets the supplied path.
|
||||
|
||||
The path is copied, if \a path is \c NULL the path of the object is set to
|
||||
\c NULL as well. The old path is deleted.
|
||||
|
||||
\param path the path to be set
|
||||
|
||||
\returns A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_NO_MEMORY Insufficient memory.
|
||||
*/
|
||||
status_t
|
||||
BPath::_SetPath(const char* path)
|
||||
{
|
||||
@ -519,7 +530,19 @@ BPath::_SetPath(const char* path)
|
||||
}
|
||||
|
||||
|
||||
// Checks a path to see if normalization is required.
|
||||
/*! Checks a path to see if normalization is required.
|
||||
|
||||
The following items require normalization:
|
||||
- Relative pathnames (after concatenation; e.g. "boot/ltj")
|
||||
- The presence of "." or ".." ("/boot/ltj/../ltj/./gwar")
|
||||
- Redundant slashes ("/boot//ltj")
|
||||
- A trailing slash ("/boot/ltj/")
|
||||
|
||||
\param _error A pointer to an error variable that will be set if the input
|
||||
is not a valid path.
|
||||
|
||||
\return \c true if \a path requires normalization, \c false otherwise.
|
||||
*/
|
||||
bool
|
||||
BPath::_MustNormalize(const char* path, status_t* _error)
|
||||
{
|
||||
|
@ -399,7 +399,10 @@ BQuery::CountEntries()
|
||||
}
|
||||
|
||||
|
||||
// Gets whether Fetch() has already been called on this object.
|
||||
/*! Gets whether Fetch() has already been called on this object.
|
||||
|
||||
\return \c true, if Fetch() was already called, \c false otherwise.
|
||||
*/
|
||||
bool
|
||||
BQuery::_HasFetched() const
|
||||
{
|
||||
@ -407,7 +410,27 @@ BQuery::_HasFetched() const
|
||||
}
|
||||
|
||||
|
||||
// Pushes a node onto the predicate stack.
|
||||
/*! Pushes a node onto the predicate stack.
|
||||
|
||||
If the stack has not been allocate until this time, this method does
|
||||
allocate it.
|
||||
|
||||
If the supplied node is \c NULL, it is assumed that there was not enough
|
||||
memory to allocate the node and thus \c B_NO_MEMORY is returned.
|
||||
|
||||
In case the method fails, the caller retains the ownership of the supplied
|
||||
node and thus is responsible for deleting it, if \a deleteOnError is
|
||||
\c false. If it is \c true, the node is deleted, if an error occurs.
|
||||
|
||||
\param node The node to push.
|
||||
\param deleteOnError Whether or not to delete the node if an error occurs.
|
||||
|
||||
\return A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_NO_MEMORY \a node was \c NULL or there was insufficient memory to
|
||||
allocate the predicate stack or push the node.
|
||||
\retval B_NOT_ALLOWED _PushNode() was called after Fetch().
|
||||
*/
|
||||
status_t
|
||||
BQuery::_PushNode(QueryNode* node, bool deleteOnError)
|
||||
{
|
||||
@ -428,7 +451,16 @@ BQuery::_PushNode(QueryNode* node, bool deleteOnError)
|
||||
}
|
||||
|
||||
|
||||
// Helper method to set the predicate.
|
||||
/*! Helper method to set the predicate.
|
||||
|
||||
Does not check whether Fetch() has already been invoked.
|
||||
|
||||
\param expression The predicate string to set.
|
||||
|
||||
\return A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_NO_MEMORY There was insufficient memory to store the predicate.
|
||||
*/
|
||||
status_t
|
||||
BQuery::_SetPredicate(const char* expression)
|
||||
{
|
||||
@ -448,7 +480,17 @@ BQuery::_SetPredicate(const char* expression)
|
||||
}
|
||||
|
||||
|
||||
// Evaluates the predicate stack.
|
||||
/*! Evaluates the predicate stack.
|
||||
|
||||
The method does nothing (and returns \c B_OK), if the stack is \c NULL.
|
||||
If the stack is not \c null and Fetch() has already been called, this
|
||||
method fails.
|
||||
|
||||
\return A status code.
|
||||
\retval B_OK Everything went fine.
|
||||
\retval B_NO_MEMORY There was insufficient memory.
|
||||
\retval B_NOT_ALLOWED _EvaluateStack() was called after Fetch().
|
||||
*/
|
||||
status_t
|
||||
BQuery::_EvaluateStack()
|
||||
{
|
||||
@ -473,6 +515,10 @@ BQuery::_EvaluateStack()
|
||||
}
|
||||
|
||||
|
||||
/*! Fills out \a parsedPredicate with a parsed predicate string.
|
||||
|
||||
\param parsedPredicate The predicate string to fill out.
|
||||
*/
|
||||
void
|
||||
BQuery::_ParseDates(BString& parsedPredicate)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2014 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -27,9 +27,9 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
status_t GetStatBeOS(struct stat_beos* st)
|
||||
status_t GetStatBeOS(struct stat_beos* stat)
|
||||
{
|
||||
return fObject->_GetStat(st);
|
||||
return fObject->_GetStat(stat);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -48,9 +48,9 @@ BStatable::~BStatable()
|
||||
bool
|
||||
BStatable::IsFile() const
|
||||
{
|
||||
struct stat statData;
|
||||
if (GetStat(&statData) == B_OK)
|
||||
return S_ISREG(statData.st_mode);
|
||||
struct stat stat;
|
||||
if (GetStat(&stat) == B_OK)
|
||||
return S_ISREG(stat.st_mode);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -60,9 +60,9 @@ BStatable::IsFile() const
|
||||
bool
|
||||
BStatable::IsDirectory() const
|
||||
{
|
||||
struct stat statData;
|
||||
if (GetStat(&statData) == B_OK)
|
||||
return S_ISDIR(statData.st_mode);
|
||||
struct stat stat;
|
||||
if (GetStat(&stat) == B_OK)
|
||||
return S_ISDIR(stat.st_mode);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -72,9 +72,9 @@ BStatable::IsDirectory() const
|
||||
bool
|
||||
BStatable::IsSymLink() const
|
||||
{
|
||||
struct stat statData;
|
||||
if (GetStat(&statData) == B_OK)
|
||||
return S_ISLNK(statData.st_mode);
|
||||
struct stat stat;
|
||||
if (GetStat(&stat) == B_OK)
|
||||
return S_ISLNK(stat.st_mode);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -82,31 +82,37 @@ BStatable::IsSymLink() const
|
||||
|
||||
// Fills out ref with the node_ref of the node.
|
||||
status_t
|
||||
BStatable::GetNodeRef(node_ref *ref) const
|
||||
BStatable::GetNodeRef(node_ref* ref) const
|
||||
{
|
||||
status_t error = (ref ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK) {
|
||||
ref->device = statData.st_dev;
|
||||
ref->node = statData.st_ino;
|
||||
status_t result = (ref ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK) {
|
||||
ref->device = stat.st_dev;
|
||||
ref->node = stat.st_ino;
|
||||
}
|
||||
return error;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Fills out the node's UID into owner.
|
||||
status_t
|
||||
BStatable::GetOwner(uid_t *owner) const
|
||||
BStatable::GetOwner(uid_t* owner) const
|
||||
{
|
||||
status_t error = (owner ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*owner = statData.st_uid;
|
||||
return error;
|
||||
status_t result = (owner ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*owner = stat.st_uid;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -114,23 +120,27 @@ BStatable::GetOwner(uid_t *owner) const
|
||||
status_t
|
||||
BStatable::SetOwner(uid_t owner)
|
||||
{
|
||||
struct stat statData;
|
||||
statData.st_uid = owner;
|
||||
return set_stat(statData, B_STAT_UID);
|
||||
struct stat stat;
|
||||
stat.st_uid = owner;
|
||||
|
||||
return set_stat(stat, B_STAT_UID);
|
||||
}
|
||||
|
||||
|
||||
// Fills out the node's GID into group.
|
||||
status_t
|
||||
BStatable::GetGroup(gid_t *group) const
|
||||
BStatable::GetGroup(gid_t* group) const
|
||||
{
|
||||
status_t error = (group ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*group = statData.st_gid;
|
||||
return error;
|
||||
status_t result = (group ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*group = stat.st_gid;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -138,63 +148,74 @@ BStatable::GetGroup(gid_t *group) const
|
||||
status_t
|
||||
BStatable::SetGroup(gid_t group)
|
||||
{
|
||||
struct stat statData;
|
||||
statData.st_gid = group;
|
||||
return set_stat(statData, B_STAT_GID);
|
||||
struct stat stat;
|
||||
stat.st_gid = group;
|
||||
|
||||
return set_stat(stat, B_STAT_GID);
|
||||
}
|
||||
|
||||
|
||||
// Fills out perms with the node's permissions.
|
||||
// Fills out permissions with the node's permissions.
|
||||
status_t
|
||||
BStatable::GetPermissions(mode_t *perms) const
|
||||
BStatable::GetPermissions(mode_t* permissions) const
|
||||
{
|
||||
status_t error = (perms ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*perms = (statData.st_mode & S_IUMSK);
|
||||
return error;
|
||||
status_t result = (permissions ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*permissions = (stat.st_mode & S_IUMSK);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Sets the node's permissions to perms.
|
||||
// Sets the node's permissions to permissions.
|
||||
status_t
|
||||
BStatable::SetPermissions(mode_t perms)
|
||||
BStatable::SetPermissions(mode_t permissions)
|
||||
{
|
||||
struct stat statData;
|
||||
struct stat stat;
|
||||
// the FS should do the correct masking -- only the S_IUMSK part is
|
||||
// modifiable
|
||||
statData.st_mode = perms;
|
||||
return set_stat(statData, B_STAT_MODE);
|
||||
stat.st_mode = permissions;
|
||||
|
||||
return set_stat(stat, B_STAT_MODE);
|
||||
}
|
||||
|
||||
|
||||
// Fills out the size of the node's data (not counting attributes) into size.
|
||||
status_t
|
||||
BStatable::GetSize(off_t *size) const
|
||||
BStatable::GetSize(off_t* size) const
|
||||
{
|
||||
status_t error = (size ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*size = statData.st_size;
|
||||
return error;
|
||||
status_t result = (size ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*size = stat.st_size;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Fills out mtime with the last modification time of the node.
|
||||
status_t
|
||||
BStatable::GetModificationTime(time_t *mtime) const
|
||||
BStatable::GetModificationTime(time_t* mtime) const
|
||||
{
|
||||
status_t error = (mtime ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*mtime = statData.st_mtime;
|
||||
return error;
|
||||
status_t result = (mtime ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*mtime = stat.st_mtime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -202,23 +223,27 @@ BStatable::GetModificationTime(time_t *mtime) const
|
||||
status_t
|
||||
BStatable::SetModificationTime(time_t mtime)
|
||||
{
|
||||
struct stat statData;
|
||||
statData.st_mtime = mtime;
|
||||
return set_stat(statData, B_STAT_MODIFICATION_TIME);
|
||||
struct stat stat;
|
||||
stat.st_mtime = mtime;
|
||||
|
||||
return set_stat(stat, B_STAT_MODIFICATION_TIME);
|
||||
}
|
||||
|
||||
|
||||
// Fills out ctime with the creation time of the node
|
||||
status_t
|
||||
BStatable::GetCreationTime(time_t *ctime) const
|
||||
BStatable::GetCreationTime(time_t* ctime) const
|
||||
{
|
||||
status_t error = (ctime ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*ctime = statData.st_crtime;
|
||||
return error;
|
||||
status_t result = (ctime ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*ctime = stat.st_crtime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -226,23 +251,27 @@ BStatable::GetCreationTime(time_t *ctime) const
|
||||
status_t
|
||||
BStatable::SetCreationTime(time_t ctime)
|
||||
{
|
||||
struct stat statData;
|
||||
statData.st_crtime = ctime;
|
||||
return set_stat(statData, B_STAT_CREATION_TIME);
|
||||
struct stat stat;
|
||||
stat.st_crtime = ctime;
|
||||
|
||||
return set_stat(stat, B_STAT_CREATION_TIME);
|
||||
}
|
||||
|
||||
|
||||
// Fills out atime with the access time of the node.
|
||||
status_t
|
||||
BStatable::GetAccessTime(time_t *atime) const
|
||||
BStatable::GetAccessTime(time_t* atime) const
|
||||
{
|
||||
status_t error = (atime ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
*atime = statData.st_atime;
|
||||
return error;
|
||||
status_t result = (atime ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
*atime = stat.st_atime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -250,41 +279,45 @@ BStatable::GetAccessTime(time_t *atime) const
|
||||
status_t
|
||||
BStatable::SetAccessTime(time_t atime)
|
||||
{
|
||||
struct stat statData;
|
||||
statData.st_atime = atime;
|
||||
return set_stat(statData, B_STAT_ACCESS_TIME);
|
||||
struct stat stat;
|
||||
stat.st_atime = atime;
|
||||
|
||||
return set_stat(stat, B_STAT_ACCESS_TIME);
|
||||
}
|
||||
|
||||
|
||||
// Fills out vol with the the volume that the node lives on.
|
||||
status_t
|
||||
BStatable::GetVolume(BVolume *vol) const
|
||||
BStatable::GetVolume(BVolume* volume) const
|
||||
{
|
||||
status_t error = (vol ? B_OK : B_BAD_VALUE);
|
||||
struct stat statData;
|
||||
if (error == B_OK)
|
||||
error = GetStat(&statData);
|
||||
if (error == B_OK)
|
||||
error = vol->SetTo(statData.st_dev);
|
||||
return error;
|
||||
status_t result = (volume ? B_OK : B_BAD_VALUE);
|
||||
struct stat stat;
|
||||
if (result == B_OK)
|
||||
result = GetStat(&stat);
|
||||
|
||||
if (result == B_OK)
|
||||
result = volume->SetTo(stat.st_dev);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// _OhSoStatable1() -> GetStat()
|
||||
extern "C" status_t
|
||||
#if __GNUC__ == 2
|
||||
_OhSoStatable1__9BStatable(const BStatable *self, struct stat *st)
|
||||
_OhSoStatable1__9BStatable(const BStatable* self, struct stat* stat)
|
||||
#else
|
||||
_ZN9BStatable14_OhSoStatable1Ev(const BStatable *self, struct stat *st)
|
||||
_ZN9BStatable14_OhSoStatable1Ev(const BStatable* self, struct stat* stat)
|
||||
#endif
|
||||
{
|
||||
// No Perform() method -- we have to use the old GetStat() method instead.
|
||||
struct stat_beos oldStat;
|
||||
status_t error = BStatable::Private(self).GetStatBeOS(&oldStat);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
status_t result = BStatable::Private(self).GetStatBeOS(&oldStat);
|
||||
if (result != B_OK)
|
||||
return result;
|
||||
|
||||
convert_from_stat_beos(&oldStat, stat);
|
||||
|
||||
convert_from_stat_beos(&oldStat, st);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009, Haiku Inc.
|
||||
* Copyright 2002-2009 Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -31,16 +31,16 @@ BSymLink::BSymLink()
|
||||
|
||||
|
||||
// Creates a copy of the supplied BSymLink object.
|
||||
BSymLink::BSymLink(const BSymLink &link)
|
||||
BSymLink::BSymLink(const BSymLink& other)
|
||||
:
|
||||
BNode(link)
|
||||
BNode(other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Creates a BSymLink object and initializes it to the symbolic link referred
|
||||
// to by the supplied entry_ref.
|
||||
BSymLink::BSymLink(const entry_ref *ref)
|
||||
BSymLink::BSymLink(const entry_ref* ref)
|
||||
:
|
||||
BNode(ref)
|
||||
{
|
||||
@ -49,7 +49,7 @@ BSymLink::BSymLink(const entry_ref *ref)
|
||||
|
||||
// Creates a BSymLink object and initializes it to the symbolic link referred
|
||||
// to by the supplied BEntry.
|
||||
BSymLink::BSymLink(const BEntry *entry)
|
||||
BSymLink::BSymLink(const BEntry* entry)
|
||||
: BNode(entry)
|
||||
{
|
||||
}
|
||||
@ -57,7 +57,7 @@ BSymLink::BSymLink(const BEntry *entry)
|
||||
|
||||
// Creates a BSymLink object and initializes it to the symbolic link referred
|
||||
// to by the supplied path name.
|
||||
BSymLink::BSymLink(const char *path)
|
||||
BSymLink::BSymLink(const char* path)
|
||||
:
|
||||
BNode(path)
|
||||
{
|
||||
@ -66,7 +66,7 @@ BSymLink::BSymLink(const char *path)
|
||||
|
||||
// Creates a BSymLink object and initializes it to the symbolic link referred
|
||||
// to by the supplied path name relative to the specified BDirectory.
|
||||
BSymLink::BSymLink(const BDirectory *dir, const char *path)
|
||||
BSymLink::BSymLink(const BDirectory* dir, const char* path)
|
||||
:
|
||||
BNode(dir, path)
|
||||
{
|
||||
@ -81,7 +81,7 @@ BSymLink::~BSymLink()
|
||||
|
||||
// Reads the contents of the symbolic link into a buffer.
|
||||
ssize_t
|
||||
BSymLink::ReadLink(char *buffer, size_t size)
|
||||
BSymLink::ReadLink(char* buffer, size_t size)
|
||||
{
|
||||
if (buffer == NULL)
|
||||
return B_BAD_VALUE;
|
||||
@ -90,9 +90,9 @@ BSymLink::ReadLink(char *buffer, size_t size)
|
||||
return B_FILE_ERROR;
|
||||
|
||||
size_t linkLen = size;
|
||||
status_t error = _kern_read_link(get_fd(), NULL, buffer, &linkLen);
|
||||
if (error < B_OK)
|
||||
return error;
|
||||
status_t result = _kern_read_link(get_fd(), NULL, buffer, &linkLen);
|
||||
if (result < B_OK)
|
||||
return result;
|
||||
|
||||
// null-terminate
|
||||
if (linkLen >= size)
|
||||
@ -107,7 +107,7 @@ BSymLink::ReadLink(char *buffer, size_t size)
|
||||
// Combines a directory path and the contents of this symbolic link to form an
|
||||
// absolute path.
|
||||
ssize_t
|
||||
BSymLink::MakeLinkedPath(const char *dirPath, BPath *path)
|
||||
BSymLink::MakeLinkedPath(const char* dirPath, BPath* path)
|
||||
{
|
||||
// BeOS seems to convert the dirPath to a BDirectory, which causes links
|
||||
// to be resolved. This means that the dirPath must exist!
|
||||
@ -126,7 +126,7 @@ BSymLink::MakeLinkedPath(const char *dirPath, BPath *path)
|
||||
// Combines a directory path and the contents of this symbolic link to form an
|
||||
// absolute path.
|
||||
ssize_t
|
||||
BSymLink::MakeLinkedPath(const BDirectory *dir, BPath *path)
|
||||
BSymLink::MakeLinkedPath(const BDirectory* dir, BPath* path)
|
||||
{
|
||||
if (dir == NULL || path == NULL)
|
||||
return B_BAD_VALUE;
|
||||
@ -168,7 +168,13 @@ void BSymLink::_MissingSymLink5() {}
|
||||
void BSymLink::_MissingSymLink6() {}
|
||||
|
||||
|
||||
// Returns the file descriptor of the BSymLink.
|
||||
/*! Returns the file descriptor of the BSymLink.
|
||||
|
||||
This method should be used instead of accessing the private \c fFd member
|
||||
of the BNode directly.
|
||||
|
||||
\return The object's file descriptor, or -1 if not properly initialized.
|
||||
*/
|
||||
int
|
||||
BSymLink::get_fd() const
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,10 +23,10 @@ class NotificationMessage;
|
||||
class MimeTypeTest : public BasicTest {
|
||||
public:
|
||||
static CppUnit::Test* Suite();
|
||||
|
||||
|
||||
// This function called before *each* test added in Suite()
|
||||
void setUp();
|
||||
|
||||
|
||||
// This function called after *each* test added in Suite()
|
||||
void tearDown();
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
void SupportingAppsTest();
|
||||
void SupportedTypesTest();
|
||||
void WildcardAppsTest();
|
||||
|
||||
|
||||
void InitTest();
|
||||
void StringTest();
|
||||
void MonitoringTest();
|
||||
|
Loading…
Reference in New Issue
Block a user