FileFunctions.h
Go to the documentation of this file.
00001 /*
00002  * File: FileFunctions.h
00003  * Author: Dorian Galvez-Lopez
00004  * Date: June 2009
00005  * Description: file system functions
00006  *
00007  * 
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published by
00010  * the Free Software Foundation, either version 3 of the License, or
00011  * any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  */
00022 
00023 #ifndef __D_FILE_FUNCTIONS__
00024 #define __D_FILE_FUNCTIONS__
00025 
00026 #pragma once
00027 
00028 #include <vector>
00029 #include <string>
00030 
00031 namespace DUtils {
00032 
00033 class FileFunctions
00034 {
00035 public:
00036         
00037         /* Creates the directory 'path'. The parent directory must exist
00038          * @param path
00039          */
00040         static void MkDir(const char *path);
00041 
00042         /* Removes a directory and its content
00043          * @param path
00044          */
00045         static void RmDir(const char *path);
00046 
00047         /* Removes a file 
00048          * @param path
00049          */
00050         static void RmFile(const char *path);
00051 
00052         /* Checks the existence of a folder
00053          * @return true iif the directory exists
00054          */
00055         static bool DirExists(const char *path);
00056 
00057         /* Checks the existence of a file
00058          * @returns true iif the file exists
00059          */
00060         static bool FileExists(const char *filename);
00061 
00062         /* Returns the relative path of the files located in the path given and 
00063          * whose right path of the name matches 'right'
00064          * @param path: path to directory
00065          * @param right: string like "_L.png"
00066          * @param sorted: if true, the files are sorted alphabetically
00067          * @return path list
00068          */
00069         static std::vector<std::string> Dir(const char *path, const char *right,
00070           bool sorted = false);
00071 
00072         /* Extracts the filename of the given path
00073          * @param file path
00074          * @return file name
00075          */
00076         static std::string FileName(const std::string filepath);
00077 
00078         /* Extracts the path, file name and extension of the given path
00079          * @param filepath
00080          * @param path (out): path to file
00081          * @param filename (out): filename without extension or dot
00082          * @param ext (out): extension without dot
00083          */
00084         static void FileParts(const std::string filepath, std::string &path, 
00085                 std::string &filename, std::string &ext);
00086         
00087 };
00088 
00089 }
00090 
00091 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:08