X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2FETL%2F_stringf.h;h=5c3642a356465cf763476d164d9ec6bbe9652c51;hb=8fd07c649f1bdc488aa8e2f9c2a522ca689b798f;hp=d26645332204aa912cd68c1b805cf56d321a3b59;hpb=8224d4967d9e833d55177b83a4aaf41fc664541b;p=synfig.git diff --git a/ETL/trunk/ETL/_stringf.h b/ETL/trunk/ETL/_stringf.h index d266453..5c3642a 100644 --- a/ETL/trunk/ETL/_stringf.h +++ b/ETL/trunk/ETL/_stringf.h @@ -1,7 +1,7 @@ /* ========================================================================= ** Extended Template and Library ** stringf Prodecure Implementation -** $Id: _stringf.h,v 1.1.1.1 2005/01/04 01:31:48 darco Exp $ +** $Id$ ** ** Copyright (c) 2002 Robert B. Quattlebaum Jr. ** @@ -31,6 +31,7 @@ #include #include +#include /* === M A C R O S ========================================================= */ @@ -195,7 +196,7 @@ is_absolute_path(const std::string &path) #ifdef WIN32 if(path.size()>=3 && path[1]==':' && (path[2]=='\\' || path[2]=='/')) return true; -#endif +#endif if(!path.empty() && path[0]==ETL_DIRECTORY_SEPERATOR) return true; return false; @@ -235,7 +236,7 @@ get_root_from_path(std::string path) { std::string ret; std::string::const_iterator iter; - + for(iter=path.begin();iter!=path.end();++iter) { if(*iter==ETL_DIRECTORY_SEPERATOR) @@ -268,7 +269,7 @@ cleanup_path(std::string path) std::string ret; while(basename(path)==".")path=dirname(path); - + while(!path.empty()) { std::string dir(get_root_from_path(path)); @@ -282,7 +283,7 @@ cleanup_path(std::string path) } path=remove_root_from_path(path); } - + // Remove any trailing directory seperators if(ret.size() && ret[ret.size()-1]==ETL_DIRECTORY_SEPERATOR) { @@ -295,7 +296,7 @@ inline std::string absolute_path(std::string path) { std::string ret(current_working_directory()); - + if(path.empty()) return cleanup_path(ret); if(is_absolute_path(path)) @@ -306,14 +307,14 @@ absolute_path(std::string path) inline std::string relative_path(std::string curr_path,std::string dest_path) -{ +{ // If dest_path is already a relative path, // then there is no need to do anything. if(!is_absolute_path(dest_path)) dest_path=absolute_path(dest_path); else dest_path=cleanup_path(dest_path); - + if(!is_absolute_path(curr_path)) curr_path=absolute_path(curr_path); else @@ -332,7 +333,7 @@ relative_path(std::string curr_path,std::string dest_path) { return basename(dest_path); } - + while(!dest_path.empty() && !curr_path.empty() && get_root_from_path(dest_path)==get_root_from_path(curr_path)) { dest_path=remove_root_from_path(dest_path); @@ -344,7 +345,7 @@ relative_path(std::string curr_path,std::string dest_path) dest_path=std::string("..")+ETL_DIRECTORY_SEPERATOR+dest_path; curr_path=remove_root_from_path(curr_path); } - + return dest_path; }