ZenLib
FileName.h
Go to the documentation of this file.
1 // ZenLib::FileName - FileName functions
2 // Copyright (C) 2007-2011 MediaArea.net SARL, Info@MediaArea.net
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 //
8 // Permission is granted to anyone to use this software for any purpose,
9 // including commercial applications, and to alter it and redistribute it
10 // freely, subject to the following restrictions:
11 //
12 // 1. The origin of this software must not be misrepresented; you must not
13 // claim that you wrote the original software. If you use this software
14 // in a product, an acknowledgment in the product documentation would be
15 // appreciated but is not required.
16 // 2. Altered source versions must be plainly marked as such, and must not be
17 // misrepresented as being the original software.
18 // 3. This notice may not be removed or altered from any source distribution.
19 //
20 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
22 //
23 // File name related functions
24 //
25 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
26 
27 //---------------------------------------------------------------------------
28 #ifndef ZenLib_FileNameH
29 #define ZenLib_FileNameH
30 //---------------------------------------------------------------------------
31 
32 //---------------------------------------------------------------------------
33 #include "ZenLib/Conf.h"
34 #include "ZenLib/Ztring.h"
35 //---------------------------------------------------------------------------
36 
37 namespace ZenLib
38 {
39 
40 //***************************************************************************
41 /// @brief File name manipulation
42 //***************************************************************************
43 
44 class FileName : public ZenLib::Ztring
45 {
46 public :
47  //Constructor/Destructor
48  FileName () : Ztring(){};
49  FileName (const tstring& str) : Ztring(str){};
50  FileName (const tstring& str, size_type pos, size_type n=npos) : Ztring(str, pos, n){};
51  FileName (const Char* s, size_type n) : Ztring(s, n){};
52  FileName (const Char* s) : Ztring(s){};
53  FileName (size_type n, char c) : Ztring(n, c){};
54 
55  //Read/Write
56  ZenLib::Ztring Path_Get () const;
57  ZenLib::Ztring Name_Get () const;
59  ZenLib::Ztring& Path_Set (const Ztring &Path);
60  ZenLib::Ztring& Name_Set (const Ztring &Name);
61  ZenLib::Ztring& Extension_Set (const Ztring &Extension);
62 
63  //Helpers
64  static ZenLib::Ztring Path_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Path_Get();};
65  static ZenLib::Ztring Name_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Name_Get();};
66  static ZenLib::Ztring Extension_Get (const Ztring &File_Name) {return ((FileName&)File_Name).Extension_Get();};
67  static ZenLib::Ztring TempFileName_Create (const Ztring &Prefix);
68 };
69 
70 //Platform differences
71 extern const Char* FileName_PathSeparator;
72 
73 } //NameSpace
74 
75 //---------------------------------------------------------------------------
76 #ifdef __BORLANDC__
77  #pragma warn .8027
78 #endif
79 //---------------------------------------------------------------------------
80 
81 #endif