2009-05-18 13:09:23 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2009, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-08-12 11:24:02 +04:00
|
|
|
#ifndef _PATH_H
|
|
|
|
#define _PATH_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-05-18 13:09:23 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <Flattenable.h>
|
2009-05-18 13:09:23 +04:00
|
|
|
#include <Message.h>
|
2002-10-23 17:45:47 +04:00
|
|
|
#include <StorageDefs.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
class BDirectory;
|
|
|
|
class BEntry;
|
|
|
|
struct entry_ref;
|
|
|
|
|
2009-05-18 13:09:23 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BPath : public BFlattenable {
|
|
|
|
public:
|
2009-05-18 13:09:23 +04:00
|
|
|
BPath();
|
|
|
|
BPath(const BPath& path);
|
|
|
|
BPath(const entry_ref* ref);
|
|
|
|
BPath(const BEntry* entry);
|
|
|
|
BPath(const char* dir, const char* leaf = NULL,
|
|
|
|
bool normalize = false);
|
2009-06-10 00:41:04 +04:00
|
|
|
BPath(const BDirectory* dir,
|
|
|
|
const char* leaf = NULL,
|
2009-05-18 13:09:23 +04:00
|
|
|
bool normalize = false);
|
|
|
|
|
|
|
|
virtual ~BPath();
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
|
|
|
|
status_t SetTo(const entry_ref* ref);
|
|
|
|
status_t SetTo(const BEntry* entry);
|
|
|
|
status_t SetTo(const char* path, const char* leaf = NULL,
|
|
|
|
bool normalize = false);
|
2009-06-10 00:41:04 +04:00
|
|
|
status_t SetTo(const BDirectory* dir,
|
|
|
|
const char* leaf = NULL,
|
2009-05-18 13:09:23 +04:00
|
|
|
bool normalize = false);
|
|
|
|
void Unset();
|
|
|
|
|
|
|
|
status_t Append(const char* path, bool normalize = false);
|
|
|
|
|
|
|
|
const char* Path() const;
|
|
|
|
const char* Leaf() const;
|
|
|
|
status_t GetParent(BPath* path) const;
|
|
|
|
|
|
|
|
bool operator==(const BPath& item) const;
|
|
|
|
bool operator==(const char* path) const;
|
|
|
|
bool operator!=(const BPath& item) const;
|
|
|
|
bool operator!=(const char* path) const;
|
|
|
|
BPath& operator=(const BPath& item);
|
|
|
|
BPath& operator=(const char* path);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// BFlattenable protocol
|
2009-05-18 13:09:23 +04:00
|
|
|
virtual bool IsFixedSize() const;
|
|
|
|
virtual type_code TypeCode() const;
|
|
|
|
virtual ssize_t FlattenedSize() const;
|
|
|
|
virtual status_t Flatten(void* buffer, ssize_t size) const;
|
|
|
|
virtual bool AllowsTypeCode(type_code code) const;
|
|
|
|
virtual status_t Unflatten(type_code code, const void* buffer,
|
|
|
|
ssize_t size);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2009-05-18 13:09:23 +04:00
|
|
|
virtual void _WarPath1();
|
|
|
|
virtual void _WarPath2();
|
|
|
|
virtual void _WarPath3();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-05-18 13:09:23 +04:00
|
|
|
status_t _SetPath(const char* path);
|
|
|
|
static bool _MustNormalize(const char* path, status_t* _error);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-05-18 13:09:23 +04:00
|
|
|
uint32 _reserved[4];
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-05-18 13:09:23 +04:00
|
|
|
char* fName;
|
|
|
|
status_t fCStatus;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2002-08-12 11:24:02 +04:00
|
|
|
#endif // _PATH_H
|