RWFileStat is an abstraction of the state of a file system object and provides that information in a portable manner. Note that RWFileStat type is not assignable, copy constructible, or equality comparable:
// ... RWFileStat s0 ("somefile.txt"); RWFileStat s1; s1 = s0; // fail; not Assignable RWFileStat s2 (s0); // fail; not Copy Constructible return s0 == s1; // fail; not Comparable // .... |
Construct an RWFileState object by passing the name of a valid file:
RWFileStat st ("filename"); |
For links, the RWFileStat object will stat the link object itself and not the target of the symbolic link. If you want to stat the target use:
RWFileStat st ("filename", true); |
A function which prints the type of the file system object stat'ed:
void list_type (const char* filename) { try { RWFileStat st (filename); // print type if (st.isSymlink ()) std::cout << " symlink"; if (st.isFile ()) std::cout << " file"; if (st.isBlock ()) std::cout << " block"; if (st.isDirectory ()) std::cout << " directory"; if (st.isCharacter ()) std::cout << " character"; if (st.isFifo ()) std::cout << " FIFO"; // List the file mode std::cout << " 0x" << std::hex << std::setw (8) << std::setfill('0') << st.mode () << std::endl; } catch (const RWInternalErr& e) { std::cerr << " Exception : " << e.why (); } catch (...) { std::cerr << " Unknown exception."; } } |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.