Opened 7 years ago

Closed 13 months ago

#854 closed discussion (wontfix)

avoid using non-standard sys/stat.h

Reported by: Peter Owned by: Peter
Priority: major Milestone:
Component: utility Version: trunk
Keywords: Cc:

Description

We use <sys/stat.h> in FileUtil and in utility/utility.cc. The header <sys/stat.h> is required in POSIX and provides e.g. the stat struct. But it is not required in C++ standard, so it is a bit ugly that we use it here. It would be fairly easy to re-implement FileUtil using boost::filesystem, which might take care of some corner cases. Same think for functions like mkdir, mkdir_p, and remove.

Change History (2)

comment:1 Changed 13 months ago by Peter

Milestone: yat 0.x+yat 0.20
Owner: changed from Jari Häkkinen to Peter
Status: newaccepted

I'll have a go at this. If it's straightforward, it'll be included in 0.20.

comment:2 Changed 13 months ago by Peter

Milestone: yat 0.20
Resolution: wontfix
Status: acceptedclosed

While most of the functionality is directly available in boost::filesystem (included in c++17) and many functions could be simplified to a simple call to boost, plus some care to not change the type of exception thrown in case of error. But FileUtil::permissions looks like a bit of pain to reimplement. There is a function to retrieve all the permission bits, but with all I mean all, that is, bits for the owner, bits for the group and both for the world. In the current implementation, we call access to check if we have r/w/x permission for the file and access figures out whether we're the owner or member of the group, to work out which permission that is relevant. I suppose it's possible to reproduce that behaviour via boost interface, but I'm not sure how and I think it's too tedious and error prone to dig into. Trying to build yat on a system without <sys/stat.h> that system either should put in a museum or one will have problem to even run configure.

Note: See TracTickets for help on using tickets.