Ignore:
Timestamp:
Dec 20, 2006, 10:49:02 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Addresses #1 and #80. Issues fixed, but bogus params to functions exists. cleanup needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/FileIO.h

    r687 r709  
    2727*/
    2828
     29#include "Exception.h"
     30
    2931#include <string>
    30 
     32#include <sys/stat.h>
    3133#include <unistd.h>
    3234
     
    4244
    4345    ///
     46    /// \brief Constructor
     47    ///
     48    /// \exception IO_error if underlying stat(2) call fails in other
     49    /// ways than file does not exist.
     50    ///
     51    explicit FileIO(const std::string& path);
     52
     53    ///
     54    /// @brief Check file/directory permissions
     55    ///
    4456    /// Check if access permissions match \a mode. \a mode must be
    4557    /// given as r, w, x, or combinations of these letters.
     58    ///
     59    /// @note Checking permissions on a non-existent file will return
     60    /// the permissions for the parent directory, but only the parent
     61    /// directory. If the parent directory does not exist then fail is
     62    /// returned.
    4663    ///
    4764    /// @return On success (all requested permissions granted), zero
     
    5067    /// is returned, and errno is set appropriately.
    5168    ///
    52     /// @see access(2)
    53     ///
    54     /// @note Checking for write permissions will fail if the file
    55     /// does not exists. This should be fixed so that when a file does
    56     /// not exist, permissions to create the file should be returned.
    57     ///
    5869    int access_rights(const std::string& path,const std::string& bits) const;
    5970
    6071    ///
    61     /// Check whether \a file exists.
     72    /// @brief Check whether \a file exists.
    6273    ///
    6374    /// @return True if \a file exists, false otherwise.
    6475    ///
    65     /// @see access(2)
     76    bool file_exists(const std::string& file) const;
     77
    6678    ///
    67     /// @todo Probably stat(2) should be used in favour of
    68     /// access(2). Change the implementation.
     79    /// @brief Get path associated with the object.
    6980    ///
    70     inline bool file_exists(const std::string& file) const
    71       { return !access(file.c_str(),F_OK); }
     81    const std::string& path(void) const;
     82
     83  private:
     84    ///
     85    /// \brief The copy constructor, not implemented
     86    ///
     87    FileIO(const FileIO&);
     88
     89    bool no_file_;
     90    std::string path_;
     91    struct stat stat_;
    7292  };
    7393
Note: See TracChangeset for help on using the changeset viewer.