boost::filesystem::path - where are the attributes?
I'm not sure if I'm missing something or not, but I couldn't find anything in the filesystem documentation that allows one to retrieve file/directory attributes such as: Date created/last accessed/last modified Hidden System Read Only Link Etc. I'm particularly interested in portable file date accessors (hoping to find methods in the path class returning boost::posix_time::ptime). Are there any known workarounds?
I create two additional boost::filesystem convenience functions: 1) boost::filesystem::is_match(): Compare a given ::boost::filesystem::path object with a file pattern. Throws a boost::filesystem::filesystem_error object if ph does not exists or is not a path to a file. The pattern supports the simple '*' and '?' wildchars and does case insensitive compartes under WIN32. bool ::boost::filesystem::is_match(const fs::path & ph, const char *pattern) 2) boost::filesystem::file_dates(): Get the file dates for a given file represented by a path object. The function throws a boost::filesystem::filesystem_error object if ph does not exists or is not a path to a file. You must define the macro BOOST_FILESYSTEM_FILEDATES and link with the correct boost::date_time library in order to use file_dates() function. file_dates() fills in and returns a structure as follows: struct filedates { boost::posix_time::ptime m_file_created; boost::posix_time::ptime m_file_last_accessed; boost::posix_time::ptime m_file_last_modified; }; filedates ::boost::filesystem::file_dates(const fs::path & ph); Note: I have not yet had the time to test this under anything other than VC++ 6.0 (yikes! yea I know - sorry) but if nobody else does this, I'll test it under Linux RH9/gcc3.2 (and HP-UX 11/aCC if I find the time) sometimes in the next week or so. Pete
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Pete Sent: Tuesday, 16 November 2004 9:52 AM To: boost-users@lists.boost.org Subject: [Boost-users] boost::filesystem::path - where are the attributes?
I'm not sure if I'm missing something or not, but I couldn't find anything in the filesystem documentation that allows one to retrieve file/directory attributes such as:
Date created/last accessed/last modified Hidden System Read Only Link Etc.
I'm particularly interested in portable file date accessors (hoping to find methods in the path class returning boost::posix_time::ptime). Are there any known workarounds?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/bo> ost-users
At 03:51 PM 11/15/2004, Pete wrote:
I'm not sure if I'm missing something or not, but I couldn't find anything in the filesystem documentation that allows one to retrieve file/directory attributes such as:
Date created/last accessed/last modified Hidden System Read Only Link Etc.
I'm particularly interested in portable file date accessors (hoping to find methods in the path class returning boost::posix_time::ptime). Are there any known workarounds?
The last_write_time() function supplies the last modified date/time. The symbolic_link_exists() helps with symlinks. The bulk of the other attributes you mention are not currently supported by the filesystem library because we don't know a portable way to do so, even just between Wiindows and POSIX, let alone other systems. We've talked a lot about identifying some set of POSIX attributes that would sensibly map into a "read_only" query function, but no one has stepped forward to actually do a trial implementation. HTH, --Beman
participants (2)
-
Beman Dawes
-
Pete