DCL 4.0
Loading...
Searching...
No Matches
Files.h
Go to the documentation of this file.
1#ifndef __DCL_FILES_H__
2#define __DCL_FILES_H__ 20241218
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/Config.h>
6#endif
7#ifndef __DCL_STRING_H__
8#include <dcl/String.h>
9#endif
10#ifndef __DCL_CHARSET_H__
11#include <dcl/Charset.h>
12#endif
13#ifndef __DCL_DATE_TIME_H__
14#include <dcl/DateTime.h>
15#endif
16#ifndef __DCL_EXCEPTION_H__
17#include <dcl/Exception.h>
18#endif
19
20__DCL_BEGIN_NAMESPACE
21
22class InputStream;
23class OutputStream;
24
25class DCLCAPI Files
26{
27private:
28 Files() {}
29
30public:
31 // static members
32 // File2.cpp
33
35 {
38 EXECUTE_OK = 1, // windows 무시
39 EXISTS = 0,
40 };
41
47 static bool access(const String& _path, int _mode);
48
49 static void rename(const String& _oldpath, const String& _newpath)
51
52 // unlink and rmdir
53 static void remove(const String& _path)
55
56 // path를 삭제
57 static void unlink(const String& _path)
59
60 // path 의 존재 유무 체크access(path, F_OK), 있으면 true
61 // path가 심볼릭 링크이면 원본 체크
62 static bool exists(const String& _path);
63
64 // 파일의 디렉토리 여부를 판별한다.
65 static bool isDirectory(const String& _path);
66
70 static DateTime mtime(const String& _path)
72
73 /*
74 * 파일의 최종 접근, 수정, 생성 시간을 얻는다.
75 */
76 static bool time(const String& _path,
77 time_t* _atime, time_t* _mtime, time_t* _ctime);
78
79 // 파일이 없거나 접근 불능등의 에러이면 예외
80 static uint64_t size(const String& _path)
82
83 // 프로세스의 작업 디렉토리 변경
84 static void chdir(const String& _path)
86
87 // 프로세스의 현재 디렉토리(current working directory)
88 static String getcwd() __DCL_THROWS1(IOException*);
89
90 // 디렉토리 생성, windows에서 nMode 무시
91 static void mkdir(const String& _path, int _mode = 0755)
93
94 // 디렉토리 삭제
95 static void rmdir(const String& _path)
97
98 // path에서 파일명을 리턴, "dir/a" ==> "a"
99 static String basename(const String& _path);
100
101 // path에서 디렉토리명을 리턴, "dir/abc" ==> "dir/"
102 // 리턴값문자열의 끝은 디렉토리 구분자('/', '\', ':')를 포함
103 static String dirname(const String& _path);
104
105 // path에서 디렉토리 구분자(default '/')를 리턴
106 static wchar_t delimiter(const String& _path);
107
108 // pszDirName에서 디렉토리 구분자를 찾아서
109 // pszDirName + 'delimiter char + pszBaseName 리턴
110 static String filename(
111 const String& _dirname,
112 const String& _basename
113 );
114
115 // $TMP, $TEMP, /tmp 중 리턴, 셋 모두 실패하면 빈 String
116 // 리턴값문자열의 끝은 디렉토리 구분자('/', '\')를 포함
117 static String temppath();
118
119 // 상대경로명을 절대경로명으로 리턴
120 static String realpath(const String& _path)
122
123 // "dir\dir\name" return "dir/dir/name"
124 static String unixpath(const String& _path);
125
126 // \, /, "C:, D:, ... return true
127 static bool isAbsPath(const String& _path);
128
129 static ByteString readBytes(InputStream& _input, size_t _n = (size_t)-1)
131
132 static ByteString readBytes(const String& _filename, size_t _n = (size_t)-1)
134
135 // UTF8, UTF16, UTF32, LC_CTYPE
136 static String readText(const String& _filename)
138
139 static String readText(const String& _filename, CharsetDecoder& _decoder)
141
142 static size_t copy(InputStream& _input, OutputStream& _output)
144};
145
146__DCL_END_NAMESPACE
147
148#endif // __DCL_FILES_H__
#define DCLCAPI
Definition Config.h:100
#define __DCL_THROWS1(e)
Definition Config.h:167
AccessType
Definition Files.h:35
@ EXISTS
Definition Files.h:39
@ READ_OK
Definition Files.h:36
@ WRITE_OK
Definition Files.h:37
@ EXECUTE_OK
Definition Files.h:38