* BEntry::GetStat() and BNode::GetStat() used sizeof(struct stat) for the kernel
syscall, but they could not know if R5 code called them (in which case the stat size has a different size). We now always only return the R5 stat structure here. This fixes bug #420. We might want to find a different solution to this problem, though. * Be got SYMLINK_MAX wrong - it's not the maximum number of links (that's SYMLOOP_MAX), but the maximum size of a symlink buffer. Added missing SYMLOOP_MAX and SYMLINK_MAX constants to limits.h. * Fixes MAXSYMLINKS to use SYMLOOP_MAX, instead of SYMLINKS_MAX (which doesn't exist in POSIX specs, but we (intentionally) break source compatibility here). * Reenabled the Haiku versions of stat(), fstat(), and lstat() when build for Haiku. * Removed OpenBeOS namespace stuff from the files I touched. * Removed superfluous StorageDefs.Private.h, whyever that ended up in a public header is beyond me. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17894 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,114 +1,84 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Directory.h
|
||||
BDirectory interface declaration.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DIRECTORY_H
|
||||
#define _DIRECTORY_H
|
||||
|
||||
|
||||
#include <Node.h>
|
||||
#include <EntryList.h>
|
||||
#include <StorageDefs.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
class BSymLink;
|
||||
|
||||
/*!
|
||||
\class BDirectory
|
||||
\brief A directory in the filesystem
|
||||
|
||||
Provides an interface for manipulating directories and their contents.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
\author <a href="mailto:[email protected]">Tyler Dauwalder</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BDirectory : public BNode, public BEntryList {
|
||||
public:
|
||||
BDirectory();
|
||||
BDirectory(const BDirectory &dir);
|
||||
BDirectory(const entry_ref *ref);
|
||||
BDirectory(const node_ref *nref);
|
||||
BDirectory(const BEntry *entry);
|
||||
BDirectory(const char *path);
|
||||
BDirectory(const BDirectory *dir, const char *path);
|
||||
public:
|
||||
BDirectory();
|
||||
BDirectory(const BDirectory &dir);
|
||||
BDirectory(const entry_ref *ref);
|
||||
BDirectory(const node_ref *nref);
|
||||
BDirectory(const BEntry *entry);
|
||||
BDirectory(const char *path);
|
||||
BDirectory(const BDirectory *dir, const char *path);
|
||||
|
||||
virtual ~BDirectory();
|
||||
virtual ~BDirectory();
|
||||
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const node_ref *nref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path);
|
||||
status_t SetTo(const BDirectory *dir, const char *path);
|
||||
status_t SetTo(const entry_ref *ref);
|
||||
status_t SetTo(const node_ref *nref);
|
||||
status_t SetTo(const BEntry *entry);
|
||||
status_t SetTo(const char *path);
|
||||
status_t SetTo(const BDirectory *dir, const char *path);
|
||||
|
||||
status_t GetEntry(BEntry *entry) const;
|
||||
status_t GetEntry(BEntry *entry) const;
|
||||
|
||||
bool IsRootDirectory() const;
|
||||
bool IsRootDirectory() const;
|
||||
|
||||
status_t FindEntry(const char *path, BEntry *entry,
|
||||
bool traverse = false) const;
|
||||
status_t FindEntry(const char *path, BEntry *entry,
|
||||
bool traverse = false) const;
|
||||
|
||||
bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
|
||||
bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
|
||||
bool Contains(const char *path, int32 nodeFlags = B_ANY_NODE) const;
|
||||
bool Contains(const BEntry *entry, int32 nodeFlags = B_ANY_NODE) const;
|
||||
|
||||
status_t GetStatFor(const char *path, struct stat *st) const;
|
||||
status_t GetStatFor(const char *path, struct stat *st) const;
|
||||
|
||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
||||
virtual status_t GetNextRef(entry_ref *ref);
|
||||
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
||||
int32 count = INT_MAX);
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
virtual status_t GetNextEntry(BEntry *entry, bool traverse = false);
|
||||
virtual status_t GetNextRef(entry_ref *ref);
|
||||
virtual int32 GetNextDirents(dirent *buf, size_t bufSize,
|
||||
int32 count = INT_MAX);
|
||||
virtual status_t Rewind();
|
||||
virtual int32 CountEntries();
|
||||
|
||||
status_t CreateDirectory(const char *path, BDirectory *dir);
|
||||
status_t CreateFile(const char *path, BFile *file,
|
||||
bool failIfExists = false);
|
||||
status_t CreateSymLink(const char *path, const char *linkToPath,
|
||||
BSymLink *link);
|
||||
status_t CreateDirectory(const char *path, BDirectory *dir);
|
||||
status_t CreateFile(const char *path, BFile *file,
|
||||
bool failIfExists = false);
|
||||
status_t CreateSymLink(const char *path, const char *linkToPath,
|
||||
BSymLink *link);
|
||||
|
||||
BDirectory &operator=(const BDirectory &dir);
|
||||
BDirectory &operator=(const BDirectory &dir);
|
||||
|
||||
private:
|
||||
friend class BNode;
|
||||
private:
|
||||
friend class BNode;
|
||||
friend class BEntry;
|
||||
friend class BFile;
|
||||
|
||||
virtual void _ErectorDirectory1();
|
||||
virtual void _ErectorDirectory2();
|
||||
virtual void _ErectorDirectory3();
|
||||
virtual void _ErectorDirectory4();
|
||||
virtual void _ErectorDirectory5();
|
||||
virtual void _ErectorDirectory6();
|
||||
virtual void _ErectorDirectory1();
|
||||
virtual void _ErectorDirectory2();
|
||||
virtual void _ErectorDirectory3();
|
||||
virtual void _ErectorDirectory4();
|
||||
virtual void _ErectorDirectory5();
|
||||
virtual void _ErectorDirectory6();
|
||||
|
||||
private:
|
||||
virtual void close_fd();
|
||||
int get_fd() const;
|
||||
private:
|
||||
virtual void close_fd();
|
||||
int get_fd() const;
|
||||
|
||||
private:
|
||||
uint32 _reservedData[7];
|
||||
int fDirFd;
|
||||
|
||||
friend class BEntry;
|
||||
friend class BFile;
|
||||
private:
|
||||
uint32 _reservedData[7];
|
||||
int fDirFd;
|
||||
};
|
||||
|
||||
|
||||
// C functions
|
||||
|
||||
status_t create_directory(const char *path, mode_t mode);
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // _DIRECTORY_H
|
||||
|
||||
|
||||
|
||||
+42
-68
@@ -1,89 +1,63 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file File.h
|
||||
BFile interface declaration.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _FILE_H
|
||||
#define _FILE_H
|
||||
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <Node.h>
|
||||
#include <StorageDefs.Private.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class BFile
|
||||
\brief BFile is a wrapper class for common operations on files providing
|
||||
access to the file's content data and its attributes.
|
||||
|
||||
A BFile represents a file in some file system. It implements the
|
||||
BPositionIO interface and thus the methods to read from and write to the
|
||||
file, and is derived of BNode to provide access to the file's attributes.
|
||||
|
||||
\author <a href='mailto:[email protected]'>Ingo Weinhold</a>
|
||||
|
||||
\version 0.0.0
|
||||
*/
|
||||
class BFile : public BNode, public BPositionIO {
|
||||
public:
|
||||
BFile();
|
||||
BFile(const BFile &file);
|
||||
BFile(const entry_ref *ref, uint32 openMode);
|
||||
BFile(const BEntry *entry, uint32 openMode);
|
||||
BFile(const char *path, uint32 openMode);
|
||||
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
virtual ~BFile();
|
||||
public:
|
||||
BFile();
|
||||
BFile(const BFile &file);
|
||||
BFile(const entry_ref *ref, uint32 openMode);
|
||||
BFile(const BEntry *entry, uint32 openMode);
|
||||
BFile(const char *path, uint32 openMode);
|
||||
BFile(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
virtual ~BFile();
|
||||
|
||||
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
||||
status_t SetTo(const BEntry *entry, uint32 openMode);
|
||||
status_t SetTo(const char *path, uint32 openMode);
|
||||
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
status_t SetTo(const entry_ref *ref, uint32 openMode);
|
||||
status_t SetTo(const BEntry *entry, uint32 openMode);
|
||||
status_t SetTo(const char *path, uint32 openMode);
|
||||
status_t SetTo(const BDirectory *dir, const char *path, uint32 openMode);
|
||||
|
||||
bool IsReadable() const;
|
||||
bool IsWritable() const;
|
||||
bool IsReadable() const;
|
||||
bool IsWritable() const;
|
||||
|
||||
virtual ssize_t Read(void *buffer, size_t size);
|
||||
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
|
||||
virtual ssize_t Write(const void *buffer, size_t size);
|
||||
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
|
||||
virtual ssize_t Read(void *buffer, size_t size);
|
||||
virtual ssize_t ReadAt(off_t location, void *buffer, size_t size);
|
||||
virtual ssize_t Write(const void *buffer, size_t size);
|
||||
virtual ssize_t WriteAt(off_t location, const void *buffer, size_t size);
|
||||
|
||||
virtual off_t Seek(off_t offset, uint32 seekMode);
|
||||
virtual off_t Position() const;
|
||||
virtual off_t Seek(off_t offset, uint32 seekMode);
|
||||
virtual off_t Position() const;
|
||||
|
||||
virtual status_t SetSize(off_t size);
|
||||
virtual status_t GetSize(off_t* size) const;
|
||||
virtual status_t SetSize(off_t size);
|
||||
virtual status_t GetSize(off_t* size) const;
|
||||
|
||||
BFile &operator=(const BFile &file);
|
||||
BFile &operator=(const BFile &file);
|
||||
|
||||
private:
|
||||
virtual void _PhiloFile1();
|
||||
virtual void _PhiloFile2();
|
||||
virtual void _PhiloFile3();
|
||||
virtual void _PhiloFile4();
|
||||
virtual void _PhiloFile5();
|
||||
virtual void _PhiloFile6();
|
||||
private:
|
||||
virtual void _PhiloFile1();
|
||||
virtual void _PhiloFile2();
|
||||
virtual void _PhiloFile3();
|
||||
virtual void _PhiloFile4();
|
||||
virtual void _PhiloFile5();
|
||||
virtual void _PhiloFile6();
|
||||
|
||||
uint32 _reservedData[8];
|
||||
uint32 _reservedData[8];
|
||||
|
||||
private:
|
||||
int get_fd() const;
|
||||
virtual void close_fd();
|
||||
private:
|
||||
int get_fd() const;
|
||||
virtual void close_fd();
|
||||
|
||||
private:
|
||||
//! The file's open mode.
|
||||
uint32 fMode;
|
||||
private:
|
||||
//! The file's open mode.
|
||||
uint32 fMode;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif
|
||||
|
||||
#endif // _FILE_H
|
||||
|
||||
|
||||
|
||||
@@ -1,85 +1,62 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file Statable.h
|
||||
BStatable interface declaration.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _STATABLE_H
|
||||
#define _STATABLE_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
struct node_ref;
|
||||
class BVolume;
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
struct node_ref;
|
||||
class BVolume;
|
||||
|
||||
|
||||
//! BStatable - A nice C++ wrapper to <code>stat()</code>
|
||||
/*! A purly abstract class which provieds an expenive, but convenet
|
||||
* C++ wrapper to the posix <code>\sa stat()</code> command.
|
||||
*
|
||||
* @see <a href="http://www.opensource.org/licenses/mit-license.html">MIT</a>
|
||||
* @author <a href="mailto:[email protected]"> Michael Lloyd Lee </a>
|
||||
* @author Be Inc
|
||||
* @version 0
|
||||
*/
|
||||
class BStatable {
|
||||
public:
|
||||
virtual status_t GetStat(struct stat *st) const = 0;
|
||||
public:
|
||||
virtual status_t GetStat(struct stat *st) 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 *perms) const;
|
||||
status_t SetPermissions(mode_t perms);
|
||||
|
||||
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 *vol) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
friend class BEntry;
|
||||
friend class BNode;
|
||||
|
||||
friend class BEntry;
|
||||
friend class BNode;
|
||||
virtual void _OhSoStatable1();
|
||||
virtual void _OhSoStatable2();
|
||||
virtual void _OhSoStatable3();
|
||||
uint32 _reserved[4];
|
||||
|
||||
virtual void _OhSoStatable1(); //< FBC
|
||||
virtual void _OhSoStatable2(); //< FBC
|
||||
virtual void _OhSoStatable3(); //< FBC
|
||||
uint32 _ohSoData[4]; //< FBC
|
||||
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
virtual status_t set_stat(struct stat &st, uint32 what) = 0;
|
||||
};
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
#endif // _STATABLE_H
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file StorageDefs.Private.h
|
||||
Private Storage Kit declarations needed in public headers.
|
||||
*/
|
||||
|
||||
#ifndef _DEF_STORAGE_PRIVATE_H
|
||||
#define _DEF_STORAGE_PRIVATE_H
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
typedef int FileDescriptor;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // _DEF_STORAGE_PRIVATE_H
|
||||
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
//----------------------------------------------------------------------
|
||||
// This software is part of the OpenBeOS distribution and is covered
|
||||
// by the OpenBeOS license.
|
||||
//---------------------------------------------------------------------
|
||||
/*!
|
||||
\file StorageDefs.h
|
||||
Miscellaneous Storage Kit definitions and includes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DEF_STORAGE_H
|
||||
#define _DEF_STORAGE_H
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
namespace OpenBeOS {
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
// Limits
|
||||
#define B_DEV_NAME_LENGTH 128
|
||||
@@ -24,20 +17,18 @@ namespace OpenBeOS {
|
||||
#define B_PATH_NAME_LENGTH MAXPATHLEN
|
||||
#define B_ATTR_NAME_LENGTH (B_FILE_NAME_LENGTH-1)
|
||||
#define B_MIME_TYPE_LENGTH (B_ATTR_NAME_LENGTH - 15)
|
||||
#define B_MAX_SYMLINKS SYMLINK_MAX
|
||||
|
||||
#define B_MAX_SYMLINKS SYMLOOP_MAX
|
||||
|
||||
// Open Modes
|
||||
#define B_READ_ONLY O_RDONLY // read only
|
||||
#define B_WRITE_ONLY O_WRONLY // write only
|
||||
#define B_READ_WRITE O_RDWR // read and write
|
||||
#define B_READ_ONLY O_RDONLY // read only
|
||||
#define B_WRITE_ONLY O_WRONLY // write only
|
||||
#define B_READ_WRITE O_RDWR // read and write
|
||||
|
||||
#define B_FAIL_IF_EXISTS O_EXCL // exclusive create
|
||||
#define B_CREATE_FILE O_CREAT // create the file
|
||||
#define B_ERASE_FILE O_TRUNC // erase the file's data
|
||||
#define B_OPEN_AT_END O_APPEND // point to the end of the data
|
||||
|
||||
|
||||
// Node Flavors
|
||||
enum node_flavor {
|
||||
B_FILE_NODE = 0x01,
|
||||
@@ -46,13 +37,4 @@ enum node_flavor {
|
||||
B_ANY_NODE = 0x07
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef USE_OPENBEOS_NAMESPACE
|
||||
}; // namespace OpenBeOS
|
||||
#endif // USE_OPENBEOS_NAMESPACE
|
||||
|
||||
|
||||
#endif // _DEF_STORAGE_H
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user