Local File Handling | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||
Download: |
|
|||||||||||||||||
CLocalPath lets you play with local files and folders easily: use the Current Directory concept effectively or find how many files and folders are in a given folder (and the size of everything in there too) like Windows Explorer Properties. |
IsFolderEmpty useful just before deleting a folder. FormLongPathName ensure you have the long path name. FormShortPathName returns the old DOS-type path name. GetExtension returns the extension from the given path e.g."some.html" returns "html". FormatPath Makes relative paths absolute and consistently ends folder paths with a backslash (or not). SetCurrentDirectory and SetCurrentDirectory work intelligently (SetCurrentDirectory tells you how far it got). CreatePath creates subdirectories if they don't exist. FlushDrive Empties Cached data so you can remove Removable Media without losing data. GetTempFolder finds the system temporary folder and returns the path. FindFreeFileName is useful for creating temporary files: give it a folder and a format and it returns a file-name that it knows doesn't exist in the folder yet. FileToCString reads a whole file into a string. ReportSize provides a rounded string such as "128 Bytes", "3.4 kB", "4.5 TB" etc. from a file-size. CCurrentDirectory is an RAII class to allow easy changes of directory, safe in the knowledge that the current directory will restored when the object goes out of scope. CFolderSizer Give it a root folder and it records the sizes of all the files and folders within the root and optionally provides a count of files and folders found. The CFolderSizer creates lots of little CFolderSizer children within itself to represent subdirectories. At the moment, this file uses CSV, though it really needn't! Removing that dependency is on my to-do list.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.