OSDN Git Service

rm latex/
[moflib/moflib.git] / oldmof / FilePath.cpp
1 #include "mof/FilePath.hpp"
2 #include <boost/regex.hpp>
3 #include "mof/ConsoleIO.hpp"
4
5
6 mof::FilePath::FilePath(const mof::tstring& path){
7         m_path = path;
8 }
9
10
11 mof::tstring mof::FilePath::getFormat(){
12         try {
13                 boost::regex regex("(.*)\\.(.*)");//name . format
14                 boost::smatch match;
15                 //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢
16                 if(!boost::regex_search(m_path , match , regex)){
17                         DEBUG_PRINT(_T("FormatError --- ") << m_path);
18                         return mof::tstring();
19                 }
20                 return match.str(2);    
21         }
22         catch (std::exception &e) {
23                 throw e;
24         }
25         return mof::tstring();
26 }
27                 
28
29 mof::tstring& mof::FilePath::getPath(){
30         return m_path;
31 }
32
33 mof::tstring mof::FilePath::dir(){
34         try {
35                 boost::regex regex("(.*)/[^/]*\\.(.*)");//name . format
36                 boost::smatch match;
37                 //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢
38                 if(!boost::regex_search(m_path , match , regex)){
39                         DEBUG_PRINT(_T("FormatError --- ") << m_path);
40                         return mof::tstring();
41                 }
42                 return match.str(1);    
43         }
44         catch (std::exception &e) {
45                 throw e;
46         }
47         return mof::tstring();
48
49 }
50                 
51 mof::tstring mof::FilePath::basename(){
52         try {
53                 boost::regex regex("(.*)/([^/]*)");//name . format
54                 boost::smatch match;
55                 //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢
56                 if(!boost::regex_search(m_path , match , regex)){
57                         DEBUG_PRINT(_T("FormatError --- ") << m_path);
58                         return mof::tstring();
59                 }
60                 return match.str(2);    
61         }
62         catch (std::exception &e) {
63                 throw e;
64         }
65         return mof::tstring();
66
67 }
68