VFSFile.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 _STORAGE_VFS_FILE_H
00014 #define _STORAGE_VFS_FILE_H
00015 
00016 #include <support/IStorage.h>
00017 #include <support/URL.h>
00018 
00019 #include <VFSMgr.h>
00020 
00021 #if _SUPPORTS_NAMESPACE
00022 namespace palmos {
00023 namespace storage {
00024 using namespace palmos::support;
00025 #endif
00026 
00027 class BVFSFile : public BnStorage
00028 {
00029     public:
00030         enum flags
00031         {
00032             DELETE_IF_EMPTY     = 1
00033         };
00034         
00035         
00036                             BVFSFile();
00037                             BVFSFile(const char* path, int flags, int mode=0, status_t * outResult=0);
00038                             BVFSFile(const SUrl & url, int flags, int mode=0, status_t * outResult=0);
00039                 
00040                 status_t    InitCheck() const;
00041                 
00042                 // Set the object to access the given file.  Opens the file.
00043                 status_t    SetTo(const char* path, int flags, int mode=0);
00044                 status_t    SetTo(const SUrl & url, int flags, int mode=0);
00045 
00046                 bool        IsReadable() const;
00047                 bool        IsWritable() const;
00048     
00049                 uint16_t    VolRefNum() const;  
00050 
00051                 status_t    Delete();
00052         
00053         virtual off_t       Size() const;           // query for total file size
00054         virtual status_t    SetSize(off_t size);    // resize file
00055         
00056         virtual ssize_t     ReadAtV(off_t position, const struct iovec *vector, ssize_t count);
00057         virtual ssize_t     WriteAtV(off_t position, const struct iovec *vector, ssize_t count);
00058         
00059         virtual status_t    Sync();
00060 
00061     protected:
00062         virtual             ~BVFSFile();
00063         
00064 private:
00065     status_t        m_initStatus;
00066     int             m_fd;
00067     int             m_flags;
00068     off_t           m_pos;
00069 };
00070 
00071 
00072 
00073 #if _SUPPORTS_NAMESPACE
00074 } } // namespace palmos::storage
00075 #endif
00076 
00077 #endif /* _STORAGE_VFS_FILE_H */