Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

FsPath_boost.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "FsPath.h"
00010 
00011 #include "Log.h"
00012 
00013 #include "boost/filesystem/operations.hpp"
00014 #include "boost/filesystem/convenience.hpp"
00015 #include "boost/filesystem/exception.hpp"
00016 #include "boost/version.hpp"
00017 
00018 //-----------------------------------------------------------------
00019 inline boost::filesystem::path
00020 boostPath(const std::string &file)
00021 {
00022 #if BOOST_VERSION < 103100
00023     return boost::filesystem::path(file);
00024 #else
00025     return boost::filesystem::path(file,
00026             boost::filesystem::portable_posix_name);
00027 #endif
00028 }
00029 
00030 //-----------------------------------------------------------------
00031 /**
00032  * Get native filename.
00033  * @param file posix filename
00034  */
00035     std::string
00036 FsPath::getNative(const std::string &file)
00037 {
00038     return boostPath(file).native_file_string();
00039 }
00040 //-----------------------------------------------------------------
00041 /**
00042  * Returns true when file or directory exists.
00043  * @param file posix filename
00044  */
00045     bool
00046 FsPath::exists(const std::string &file)
00047 {
00048     return boost::filesystem::exists(boostPath(file));
00049 }
00050 //-----------------------------------------------------------------
00051 /**
00052  * Joint two paths.
00053  * @param dir posix filename
00054  * @param file posix filename
00055  * @return "dir/file"
00056  */
00057     std::string
00058 FsPath::join(const std::string &dir, const std::string &file)
00059 {
00060     return (boostPath(dir) / boostPath(file)).string();
00061 }
00062 //-----------------------------------------------------------------
00063 /**
00064  * Create all directories in path (like "mkdir -p").
00065  * @param file posix filename
00066  */
00067 void
00068 FsPath::createPath(const std::string &file)
00069 {
00070     boost::filesystem::create_directories(boostPath(file).branch_path());
00071 }
00072 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2