File.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _STORAGE2_FILE_H
00014 #define _STORAGE2_FILE_H
00015 
00016 #include <support/SupportDefs.h>
00017 #include <support/IBinder.h>
00018 #include <support/IStorage.h>
00019 
00020 #include <fcntl.h>
00021 #include <sys/stat.h>
00022 
00023 
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace storage {
00027 using namespace palmos::support;
00028 #endif // _SUPPORTS_NAMESPACE
00029 
00030 class BFile;
00031 
00032 class BFile : public BnStorage
00033 {
00034 public:
00035 
00036                             BFile();
00037                             BFile(const char* path, uint32_t open_mode);
00038                             BFile(const BFile &file);
00039 
00040 #if TARGET_HOST == TARGET_HOST_BEOS
00041                             BFile(const entry_ref *ref, uint32_t open_mode);
00042                             BFile(const BEntry *entry, uint32_t open_mode);
00043                             BFile(const char *path, uint32_t open_mode);
00044                             BFile(const BCatalog *dir, const char *path,
00045                                   uint32_t open_mode);
00046 #endif
00047 
00048                 status_t    SetTo(const char* path, uint32_t open_mode);
00049 
00050 #if TARGET_HOST == TARGET_HOST_BEOS
00051                 status_t    SetTo(const entry_ref *ref, uint32_t open_mode);
00052                 status_t    SetTo(const BEntry *entry, uint32_t open_mode);
00053                 status_t    SetTo(const BCatalog *dir, const char *path,
00054                                 uint32_t open_mode);
00055 #endif
00056 
00057                 bool        IsReadable() const;
00058                 bool        IsWritable() const;
00059         
00060         virtual off_t       Size() const;
00061         virtual status_t    SetSize(off_t size);
00062 
00063         virtual ssize_t     ReadAtV(off_t position, const struct iovec* vector, ssize_t count);
00064         virtual ssize_t     WriteAtV(off_t position, const struct iovec* vector, ssize_t count);
00065         virtual status_t    Sync();
00066     
00067 protected:
00068         virtual             ~BFile();
00069         
00070 private:                
00071         int32_t             m_fd;
00072         uint32_t                m_mode;
00073 };
00074 
00075 #if _SUPPORTS_NAMESPACE
00076 } } // namespace palmos::storage
00077 #endif // _SUPPORTS_NAMESPACE
00078 
00079 #endif  // _STORAGE2_FILE_H