Home » Community » Coffee corner » File system library refactoring
File system library refactoring [message #12828] |
Mon, 19 November 2007 22:11  |
cbpporter
Messages: 1427 Registered: September 2007
|
Ultimate Contributor |
|
|
While U++ has a good file system interaction library, I think that that the non-visual parts of it are pretty low level and the visual ones also could be improved a lot.
So I started working on some high level path manipulation classes. The class PathInfo has methods such which will initialize with some OS aware abstract path:
PathInfo& FromDir(const WString &path);
PathInfo& FromFile(const WString &path);
PathInfo& FromAppDir(const WString &path);
PathInfo& FromUserDir(const WString &path);
PathInfo& FromTempDir(const WString &path);
It will also feature manipulation methods such as:
PathInfo& AddPath(const WString &path);
PathInfo& SetPath(const WString &path);
PathInfo& AddDir(const WString &path);
PathInfo& SetDir(const WString &path);
PathInfo will maintain a state and will not allow operations which are invalid on the given OS. For example, using AddDir on an object which has not been initialized with one of the From*** methods will leave the object in an invalid state and in debug mode will fail an assert.
This way, paths can be constructed in a more elegant and intuitive way that using the current functions which operate on Strings. For example, you could determine the path to store or load you ini file this way:
PathInfo iniFile;
iniFile.FromUserDir().AddPath("config").AddFile("config.ini");
And since the only way to get a valid PathInfo object is from a function or control that returns such, these objects will be safe and the code cross platform. And speaking of controls, I plan to extend/create another FileList, which will allow to implement a FileSel dialog only with a few lines of code, but can be also used as a tree or a folder select component. I would also like to emulate the native OS's look whenever possible. This means creating some dummy folders like "Computer" under Vista and inserting the real items into these. These will be purely cosmetic changes.
But for now I need to finish PathInfo first. What do you think about it? And also, I used WString instead of String.
|
|
|
Goto Forum:
Current Time: Tue May 13 12:12:49 CEST 2025
Total time taken to generate the page: 0.01103 seconds
|