TNB Library
TnbFileName.h
[詳解]
1#pragma once
15#include "TnbFile.h"
16#include "TnbStrEx.h"
17#include "TnbDntStr.h"
18#ifndef _WIN32_WCE
19 #include <SHLWAPI.h>
20 #include <shellapi.h>
21 #pragma comment(lib,"SHLWAPI.lib")
22 #include <ShObjIdl.h>
23 #include <ShlGuid.h>
24#endif
25
26
27
28//TNB Library
29namespace TNB
30{
31
32
33
34#ifndef _TnbDOXYGEN
35 #ifndef FOF_NOERRORUI
36 #define FOF_NOERRORUI 0x0400 // don't put up error UI
37 #endif
38#endif
39
40
41
59{
60public:
61
66 CFileName(void) : m_strName(TNB::GetProcessPath()), m_boIsExists(false)
67 {
68 IsExist();
69 }
70
75 CFileName(LPCTSTR lpszName) : m_boIsExists(false)
76 {
77 operator=(lpszName);
78 }
79
86 CFileName(LPCTSTR lpszName, bool dummy) : m_boIsExists(false)
87 {
88 m_strName = lpszName;
89 m_strName.TrimRight('\\');
90 IsExist();
91 }
92
98 CFileName& operator=(LPCTSTR lpszName)
99 {
100#ifndef _WIN32_WCE
101 CStr s1, s2;
102 bool r = !! ::PathSearchAndQualify(lpszName, s1.GetBuffer(MAX_PATH), MAX_PATH);
103 s1.ReleaseBuffer();
104 if ( r )
105 {
106 r = (::GetLongPathName(s1, s2.GetBuffer(MAX_PATH), MAX_PATH) != 0);
107 s2.ReleaseBuffer();
108 }
109 if ( r )
110 {
111 m_strName = s2;
112 }
113 else
114#endif
115 {
116 m_strName = lpszName;
117 }
118 m_strName.TrimRight('\\');
119 IsExist();
120 return *this;
121 }
122
129 void Set(LPCTSTR lpszName, const WIN32_FILE_ATTRIBUTE_DATA& tFileAttr)
130 {
131 m_strName = lpszName;
132 m_strName.TrimRight('\\');
133 m_tInfo = tFileAttr;
134 m_boIsExists = true;
135 }
136
143 void Set(LPCTSTR lpszPath, const WIN32_FIND_DATA& t)
144 {
145 m_strName.Format(_T("%s\\%s"), lpszPath, t.cFileName);
146 m_strName.Replace(_T("\\\\"), _T("\\"));
147 m_strName.TrimRight('\\');
148 m_tInfo.dwFileAttributes = t.dwFileAttributes;
149 m_tInfo.ftCreationTime = t.ftCreationTime;
150 m_tInfo.ftLastAccessTime = t.ftLastAccessTime;
151 m_tInfo.ftLastWriteTime = t.ftLastWriteTime;
152 m_tInfo.nFileSizeHigh = t.nFileSizeHigh;
153 m_tInfo.nFileSizeLow = t.nFileSizeLow;
154 m_boIsExists = true;
155 }
156
164 bool IsSameFile(LPCTSTR lpszName) const
165 {
166 CFileName N(lpszName);
167 CStr str = N.GetFullShortName();
168 return str.CompareNoCase(GetFullShortName()) == 0;
169 }
170
175 operator LPCTSTR(void) const
176 {
177 return m_strName;
178 }
179
184 CStr GetFullName(void) const
185 {
186 return m_strName;
187 }
188
194 {
195 #ifndef _WIN32_WCE
196 CStr str;
197 ::GetShortPathName(m_strName, str.GetBuffer(MAX_PATH), MAX_PATH);
198 str.ReleaseBuffer();
199 return str;
200 #else
201 return m_strName;
202 #endif
203 }
204
209 CStr GetFileName(void) const
210 {
211 INT_PTR p = m_strName.ReverseFindOneOf(_T("\\/"));
212 if ( p >= 0 )
213 {
214 return m_strName.Mid(p + 1);
215 }
216 return m_strName;
217 }
218
224 CStr GetFileTitle(void) const
225 {
226 CStr s = GetFileName();
227 INDEX idx = s.Find(_T('.'));
228 if ( idx != INVALID_INDEX )
229 {
230 s = s.Left(idx);
231 }
232 return s;
233 }
234
239 CStr GetShortName(void) const
240 {
242 INT_PTR p = s.ReverseFindOneOf(_T("\\/"));
243 if ( p >= 0 )
244 {
245 return s.Mid(p + 1);
246 }
247 return s;
248 }
249
254 CStr GetExtName(void) const
255 {
256 INT_PTR p = m_strName.ReverseFind('.');
257 INT_PTR p1 = m_strName.ReverseFindOneOf(_T("\\/"));
258 if ( p >= 0 && p1 < p )
259 {
260 return m_strName.Mid(p + 1);
261 }
262 return _T("");
263 }
264
269 CStr GetPathName(void) const
270 {
271 INT_PTR p = m_strName.ReverseFindOneOf(_T("\\/"));
272 if ( p >= 0 )
273 {
274 return m_strName.Left(p);
275 }
276 return m_strName;
277 }
278
285 LONGLONG GetSize(void) const
286 {
287 LONGLONG r = -1;
288 if ( m_boIsExists )
289 {
290 LARGE_INTEGER i;
291 i.HighPart = m_tInfo.nFileSizeHigh;
292 i.LowPart = m_tInfo.nFileSizeLow;
293 r = i.QuadPart;
294 }
295 return r;
296 }
297
298#ifndef _WIN32_WCE
305 LONGLONG GetSizeOnDisk(void) const
306 {
307 LONGLONG r = -1;
308 ::SetLastError(NO_ERROR);
309 CStr fn = GetFullName();
310 WIN32_FILE_ATTRIBUTE_DATA t;
311 if ( ::GetFileAttributesEx(fn, GetFileExInfoStandard, &t) )
312 {
313 LARGE_INTEGER l;
314 if ( (t.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 )
315 {
316 // DIR の場合
317 l.HighPart = t.nFileSizeHigh;
318 l.LowPart = t.nFileSizeLow;
319 r = l.QuadPart;
320 }
321 else
322 {
323 // FILE の場合
324 DWORD h;
325 l.LowPart = ::GetCompressedFileSize(fn, &h);
326 if ( ::GetLastError() == 0 )
327 {
328 l.HighPart = h;
329 r = l.QuadPart;
330 // クラスタサイズ、セクターサイズ
331 DWORD sectorsPerCluster;
332 DWORD bytesPerSector;
333 DWORD numberOfFreeClusters;
334 DWORD totalNumberOfClusters;
335 if ( ::GetDiskFreeSpace(GetPathName(), &sectorsPerCluster, &bytesPerSector, &numberOfFreeClusters, &totalNumberOfClusters) )
336 {
337 DWORD d = sectorsPerCluster * bytesPerSector; // セクター byte数
338 r = (r + d - 1) / d * d;
339 }
340 else
341 {
342 r = -1;
343 }
344 }
345 }
346 }
347 return r;
348 }
349
356 DWORD GetBytesOfCluster(void) const
357 {
358 if ( m_boIsExists )
359 {
360 CStr fn = GetFullName();
361 if ( ! IsDirectory() )
362 {
363 fn = GetPathName();
364 }
365 // クラスタサイズ、セクターサイズ
366 DWORD sectorsPerCluster;
367 DWORD bytesPerSector;
368 DWORD numberOfFreeClusters;
369 DWORD totalNumberOfClusters;
370 if ( ::GetDiskFreeSpace(GetPathName(), &sectorsPerCluster, &bytesPerSector, &numberOfFreeClusters, &totalNumberOfClusters) )
371 {
372 return sectorsPerCluster * bytesPerSector; // セクター byte数
373 }
374 }
375 return 0;
376 }
377#endif
378
386 bool GetAttributeData(LPWIN32_FILE_ATTRIBUTE_DATA P) const
387 {
388 bool r = IsExist();
389 if ( r && P != NULL )
390 {
391 *P = m_tInfo;
392 }
393 return r;
394 }
395
403 bool GetFindData(LPWIN32_FIND_DATA P) const
404 {
405 bool r = IsExist();
406 if ( r && P != NULL )
407 {
408 STRLIB::Copy(P->cFileName, GetFileName());
409 P->dwFileAttributes = m_tInfo.dwFileAttributes;
410 P->ftCreationTime = m_tInfo.ftCreationTime;
411 P->ftLastAccessTime = m_tInfo.ftLastAccessTime;
412 P->ftLastWriteTime = m_tInfo.ftLastWriteTime;
413 P->nFileSizeHigh = m_tInfo.nFileSizeHigh;
414 P->nFileSizeLow = m_tInfo.nFileSizeLow;
415 #if !defined(_WIN32_WCE)
416 STRLIB::Copy(P->cAlternateFileName, GetShortName());
417 #endif
418 }
419 return r;
420 }
421
430 CStr InsertAtEndOfName(LPCTSTR lpsz, LPCTSTR lpszExt = NULL) const
431 {
432 CStr s = GetFullName();
433 INT_PTR p = s.ReverseFind('.');
434 INT_PTR p1 = s.ReverseFindOneOf(_T("\\/"));
435 if ( p >= 0 && p1 < p )
436 {
437 if ( lpszExt != NULL )
438 {
439 return s.Left(p) + lpsz + _T(".") + lpszExt;
440 }
441 return s.Left(p) + lpsz + s.Mid(p);
442 }
443 if ( lpszExt != NULL )
444 {
445 return s + lpsz + _T(".") + lpszExt;
446 }
447 return s + lpsz;
448 }
449
455 bool IsExist(void) const
456 {
457 m_boIsExists = ms_GetInfo(m_strName, &m_tInfo);
458 return m_boIsExists;
459 }
460
466 bool IsReadOnly(void) const { return m_IsAttr(FILE_ATTRIBUTE_READONLY); }
467
473 bool IsDirectory(void) const { return m_IsAttr(FILE_ATTRIBUTE_DIRECTORY); }
474
480 bool IsCompressed(void) const { return m_IsAttr(FILE_ATTRIBUTE_COMPRESSED); }
481
487 bool IsSystem(void) const { return m_IsAttr(FILE_ATTRIBUTE_SYSTEM); }
488
494 bool IsHidden(void) const { return m_IsAttr(FILE_ATTRIBUTE_HIDDEN); }
495
501 bool IsTemporary(void) const { return m_IsAttr(FILE_ATTRIBUTE_TEMPORARY); }
502
508 bool IsNormal(void) const { return m_IsAttr(FILE_ATTRIBUTE_NORMAL); }
509
515 bool IsArchived(void) const { return m_IsAttr(FILE_ATTRIBUTE_ARCHIVE); }
516
522 {
523 CFileTimeEx ft;
524 if ( m_boIsExists ){ ft = m_tInfo.ftLastWriteTime; }
525 return ft;
526 }
527
533 {
534 CFileTimeEx ft;
535 if ( m_boIsExists ){ ft = m_tInfo.ftLastAccessTime; }
536 return ft;
537 }
538
544 {
545 CFileTimeEx ft;
546 if ( m_boIsExists ){ ft = m_tInfo.ftCreationTime; }
547 return ft;
548 }
549
555 bool SetReadOnly(void){ return m_SetAttr(FILE_ATTRIBUTE_READONLY); }
556
562 bool SetHidden(void){ return m_SetAttr(FILE_ATTRIBUTE_HIDDEN); }
563
569 bool SetNormal(void){ return m_SetAttr(FILE_ATTRIBUTE_NORMAL); }
570
579 DWORD SetTime(const CFileTimeEx& timeCreation, const CFileTimeEx& timeLastAccess, const CFileTimeEx& timeLastWrite)
580 {
581 CFileWriter file;
582 if ( file.Open(m_strName) )
583 {
584 ::SetLastError(0);
585 file.SetTime(timeCreation, timeLastAccess, timeLastWrite);
586 }
587 return ::GetLastError();
588 }
589
596 CStrVector GetFiles(LPCTSTR lpszOpt = _T("\\*.*"))
597 {
598 CStrVector vstrResult;
599 if ( IsDirectory() )
600 {
601 WIN32_FIND_DATA t;
602 HANDLE h = ::FindFirstFile(m_strName + lpszOpt, &t);
603 if ( h != INVALID_HANDLE_VALUE )
604 {
605 while ( true )
606 {
607 if ( t.cFileName[0] != '.' )
608 {
609 vstrResult.Add(CStr::Fmt(_T("%s\\%s"), m_strName, t.cFileName));
610 }
611 if ( ! ::FindNextFile(h, &t) )
612 {
613 ::FindClose(h);
614 break;
615 }
616 }
617 }
618 }
619 return vstrResult;
620 }
621
628 bool MakeDirectory(void)
629 {
630 if ( ! ::CreateDirectory(m_strName, NULL) )
631 {
632 DWORD e = ::GetLastError();
633 if ( e == ERROR_NOT_READY )
634 {
635 return false;
636 }
637 if ( e != ERROR_ALREADY_EXISTS )
638 {
639 CStr n = GetPathName();
640 if ( m_strName == n )
641 {
642 return false;
643 }
644 CFileName(n).MakeDirectory();
645 if ( ! ::CreateDirectory(m_strName, NULL) )
646 {
647 return false;
648 }
649 }
650 }
651 IsExist();
652 return true;
653 }
654
667 bool Rename(LPCTSTR lpszNew, bool boIsAllowUndo = false, bool boIsSilent = true)
668 {
669 if ( IsExist() )
670 {
671 CFileName fnNew = m_FullPath(lpszNew);
672 if ( m_ShFileOp(FO_RENAME, fnNew, boIsAllowUndo, boIsSilent) )
673 {
674 //成功
675 *this = fnNew;
676 return true;
677 }
678 }
679 return false;
680 }
681
692 bool Remove(bool boIsAllowUndo = false, bool boIsSilent = true)
693 {
694 if ( IsExist() && m_ShFileOp(FO_DELETE, NULL, boIsAllowUndo, boIsSilent) )
695 {
696 //成功
697 IsExist();
698 return true;
699 }
700 return false;
701 }
702
714 bool CopyTo(LPCTSTR lpszNew, bool boIsAllowUndo = false, bool boIsSilent = true)
715 {
716 if ( IsExist() && m_ShFileOp(FO_COPY, m_FullPath(lpszNew), boIsAllowUndo, boIsSilent) )
717 {
718 return true;
719 }
720 return false;
721 }
722
735 bool MoveTo(LPCTSTR lpszNew, bool boIsAllowUndo = false, bool boIsSilent = true)
736 {
737 if ( IsExist() )
738 {
739 CFileName fnNew = m_FullPath(lpszNew);
740 if ( m_ShFileOp(FO_MOVE, fnNew, boIsAllowUndo, boIsSilent) )
741 {
742 //成功
743 *this = fnNew;
744 return true;
745 }
746 }
747 return false;
748 }
749
759 CStr CopyEx(LPCTSTR lpszNew, bool boIsAllowUndo = false)
760 {
761 if ( IsExist() && ! IsDirectory() )
762 {
763 CStr s = lpszNew;
764 if ( IsExist(s) )
765 {
766 CStr p1 = s;
767 CStr p2;
768 INT_PTR f1 = s.ReverseFind('.');
769 INT_PTR f2 = s.ReverseFindOneOf(_T("\\/"));
770 if ( f1 >= 0 && f2 < f1 )
771 {
772 p1 = s.Left(f1);
773 p2 = s.Mid(f1);
774 }
775 loop ( i, 100000 )
776 {
777 s.Format(_T("%s(%d)%s"), p1, i + 1, p2);
778 if ( ! IsExist(s) )
779 {
780 if ( CopyTo(s, boIsAllowUndo, true) )
781 {
782 return s;
783 }
784 break;
785 }
786 }
787 }
788 else
789 {
790 if ( CopyTo(s, boIsAllowUndo, true) )
791 {
792 return s;
793 }
794 }
795 }
796 return _T("");
797 }
798
809 bool MakeShortcut(LPCTSTR lpszLinkName, LPCTSTR lpszDescription, LPCTSTR lpszParameter = NULL) const
810 {
811#ifndef _WIN32_WCE
812 // ShellLink 作成
813 IShellLink* pSL = NULL;
814 HRESULT hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
815 IID_IShellLink, reinterpret_cast<LPVOID*>(&pSL));
816 if ( SUCCEEDED(hr) )
817 {
818 pSL->SetPath(m_strName);
819 pSL->SetWorkingDirectory(GetPathName());
820 pSL->SetDescription(lpszDescription);
821 if ( lpszParameter != NULL )
822 {
823 pSL->SetArguments(lpszParameter);
824 }
825 // ShellLink から PersistFile を得る
826 IPersistFile* pPF = NULL;
827 hr = pSL->QueryInterface(IID_IPersistFile, reinterpret_cast<LPVOID*>(&pPF));
828 if ( SUCCEEDED(hr) )
829 {
830 hr = pPF->Save(CUnicode(lpszLinkName), TRUE);
831 pPF->Release();
832 pPF = NULL;
833 }
834 pSL->Release();
835 pSL = NULL;
836 }
837 return SUCCEEDED(hr);
838#else
839 CStr ln = lpszLinkName;
840 CStr fn = m_strName;
841 return !! ::SHCreateShortcut(ln.GetBuffer(MAX_PATH), fn.GetBuffer(MAX_PATH));
842#endif
843 }
844
851 bool IsShortcut(void) const
852 {
853#ifndef _WIN32_WCE
854 IShellLink* pSL = NULL;
855 HRESULT hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
856 IID_IShellLink, reinterpret_cast<LPVOID*>(&pSL));
857 if ( SUCCEEDED(hr) )
858 {
859 IPersistFile* pPF = NULL;
860 hr = pSL->QueryInterface(IID_IPersistFile, reinterpret_cast<LPVOID*>(&pPF));
861 if ( SUCCEEDED(hr) )
862 {
863 hr = pPF->Load(CUnicode(m_strName), STGM_READ);
864 pPF->Release();
865 pPF = NULL;
866 }
867 pSL->Release();
868 pSL = NULL;
869 }
870 return SUCCEEDED(hr);
871#else
872 CStr s;
873 if ( ::SHGetShortcutTarget(m_strName, s.GetBuffer(MAX_PATH), MAX_PATH) )
874 {
875 s.ReleaseBuffer();
876 return true;
877 }
878 return false;
879#endif
880 }
881
891 bool ResolveShortcut(CStr& _description, HWND hWnd = NULL)
892 {
893 #ifndef _WIN32_WCE
894 IShellLink* pSL = NULL;
895 HRESULT hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
896 IID_IShellLink, reinterpret_cast<LPVOID*>(&pSL));
897 if ( SUCCEEDED(hr) )
898 {
899 IPersistFile* pPF = NULL;
900 hr = pSL->QueryInterface(IID_IPersistFile, reinterpret_cast<LPVOID*>(&pPF));
901 if ( SUCCEEDED(hr) )
902 {
903 hr = pPF->Load(CUnicode(m_strName), STGM_READ);
904 if ( hWnd != NULL && SUCCEEDED(hr) )
905 {
906 hr = pSL->Resolve(hWnd, 0);
907 }
908 WIN32_FIND_DATA wfd;
909 CStr path;
910 if ( SUCCEEDED(hr) )
911 {
912 hr = pSL->GetPath(path.GetBuffer(MAX_PATH), MAX_PATH, &wfd, SLGP_SHORTPATH);
913 path.ReleaseBuffer();
914 }
915 if ( SUCCEEDED(hr) )
916 {
917 // Get the description of the target.
918 hr = pSL->GetDescription(_description.GetBuffer(MAX_PATH), MAX_PATH);
919 _description.ReleaseBuffer();
920 }
921 if ( SUCCEEDED(hr) )
922 {
923 operator=(path);
924 }
925 pPF->Release();
926 pPF = NULL;
927 }
928 pSL->Release();
929 pSL = NULL;
930 }
931 return SUCCEEDED(hr);
932#else
933 CStr s;
934 if ( ::SHGetShortcutTarget(m_strName, s.GetBuffer(MAX_PATH), MAX_PATH) )
935 {
936 s.ReleaseBuffer();
937 operator=(s);
938 _description.Empty();
939 return true;
940 }
941 return false;
942#endif
943 }
944
953 {
954 CStr s;
955 return ResolveShortcut(s, NULL);
956 }
957
964 static bool IsExist(LPCTSTR lpszPath)
965 {
966 return CFileName(lpszPath).IsExist();
967 }
968
969private:
971 bool m_IsAttr(DWORD dwCheck) const
972 {
973 if ( m_boIsExists )
974 {
975 return (m_tInfo.dwFileAttributes & dwCheck) != 0;
976 }
977 return false;
978 }
980 bool m_SetAttr(DWORD dwAttr)
981 {
982 bool r = !! ::SetFileAttributes(m_strName, dwAttr);
983 m_boIsExists = ms_GetInfo(m_strName, &m_tInfo);
984 return r;
985 }
987 static bool ms_GetInfo(LPCTSTR lpszName, LPWIN32_FILE_ATTRIBUTE_DATA P)
988 {
989 WIN32_FIND_DATA t;
990 HANDLE h = ::FindFirstFile(lpszName, &t);
991 if ( h != INVALID_HANDLE_VALUE )
992 {
993 ::FindClose(h);
994 P->dwFileAttributes = t.dwFileAttributes;
995 P->ftCreationTime = t.ftCreationTime;
996 P->ftLastAccessTime = t.ftLastAccessTime;
997 P->ftLastWriteTime = t.ftLastWriteTime;
998 P->nFileSizeHigh = t.nFileSizeHigh;
999 P->nFileSizeLow = t.nFileSizeLow;
1000 return true;
1001 }
1002 return false;
1003 }
1009 CStr m_FullPath(LPCTSTR lpszName)
1010 {
1011 #ifndef _WIN32_WCE
1012 CStr str;
1013 if ( ::PathIsRelative(lpszName) )
1014 {
1015 str = CStr::Fmt(_T("%s\\%s"), GetPathName(), lpszName);
1016 }
1017 else
1018 {
1019 str = lpszName;
1020 }
1021 return str;
1022 #else
1023 return lpszName;
1024 #endif
1025 }
1035 bool m_ShFileOp(WORD wFunc, LPCTSTR lpszTo, bool boIsAllowUndo, bool boIsSilent)
1036 {
1037 CDoubleNullTerminateStr strdntFrom(m_strName);
1038 return m_ShFileOp(wFunc, strdntFrom, lpszTo, boIsAllowUndo, boIsSilent);
1039 }
1050 bool m_ShFileOp(WORD wFunc, const CDoubleNullTerminateStr& strdntFrom, LPCTSTR lpszTo,
1051 bool boIsAllowUndo, bool boIsSilent)
1052 {
1053 SHFILEOPSTRUCT tFileOp;
1054 CDoubleNullTerminateStr strdntTo(lpszTo);
1055 tFileOp.hwnd = NULL; // ウィンドウハンドル
1056 tFileOp.wFunc = wFunc; // 実行する操作
1057 tFileOp.pFrom = strdntFrom; // 対象ファイル名
1058 tFileOp.pTo = NULL; // 目的ファイル名
1059 if ( lpszTo != NULL )
1060 {
1061 tFileOp.pTo = strdntTo;
1062 }
1063 tFileOp.fFlags = 0; // Flag
1064 if ( boIsSilent )
1065 {
1066 tFileOp.fFlags |= FOF_SILENT // 経過ダイアログ無し
1067 | FOF_NOCONFIRMATION// 確認で「すべて」指定
1068 | FOF_NOERRORUI; // エラー時、ダイアログを出さない
1069 }
1070 if ( boIsAllowUndo )
1071 {
1072 tFileOp.fFlags |= FOF_ALLOWUNDO; //UNDO
1073 }
1074 tFileOp.fAnyOperationsAborted = FALSE; // [out]結果
1075 tFileOp.hNameMappings = NULL; // [out]ファイル名マッピングオブジェクト
1076 tFileOp.lpszProgressTitle = _T("");
1077 return ::SHFileOperation(&tFileOp) == 0;
1078 }
1079 CStr m_strName;
1080 mutable bool m_boIsExists;
1081 mutable WIN32_FILE_ATTRIBUTE_DATA m_tInfo;
1082};
1083
1084
1085
1086}; // TNB
1087
#define loop(VAR, CNT)
loop構文.
Definition: TnbDef.h:343
Double Null Terminate(DNT)型文字列操作関係のヘッダ
ファイル関係のヘッダ
文字列処理関係のヘッダ
Double Null Terminate(DNT)型文字列管理
Definition: TnbDntStr.h:61
ファイル名管理クラス
Definition: TnbFileName.h:59
CStr GetExtName(void) const
[取得] 拡張子取得
Definition: TnbFileName.h:254
CFileTimeEx GetCreationTime(void) const
[取得] 作成日時取得
Definition: TnbFileName.h:543
bool CopyTo(LPCTSTR lpszNew, bool boIsAllowUndo=false, bool boIsSilent=true)
[操作] コピー.
Definition: TnbFileName.h:714
static bool IsExist(LPCTSTR lpszPath)
[確認] 有無チェック.
Definition: TnbFileName.h:964
bool ResolveShortcut(void)
[設定] ショートカット解決.
Definition: TnbFileName.h:952
bool SetNormal(void)
[設定] Normal属性設定
Definition: TnbFileName.h:569
bool IsDirectory(void) const
[確認] Directory属性チェック
Definition: TnbFileName.h:473
bool IsExist(void) const
[確認] 有無チェック
Definition: TnbFileName.h:455
CStr GetPathName(void) const
[取得] パス取得
Definition: TnbFileName.h:269
CFileTimeEx GetLastAccessTime(void) const
[取得] 最終アクセス日時取得
Definition: TnbFileName.h:532
bool IsReadOnly(void) const
[確認] ReadOnly属性チェック
Definition: TnbFileName.h:466
void Set(LPCTSTR lpszPath, const WIN32_FIND_DATA &t)
[設定] 代入
Definition: TnbFileName.h:143
CStr CopyEx(LPCTSTR lpszNew, bool boIsAllowUndo=false)
[操作] コピー.
Definition: TnbFileName.h:759
bool IsShortcut(void) const
[確認] Shortcutチェック
Definition: TnbFileName.h:851
bool MoveTo(LPCTSTR lpszNew, bool boIsAllowUndo=false, bool boIsSilent=true)
[操作] ムーブ.
Definition: TnbFileName.h:735
bool IsArchived(void) const
[確認] Archived属性チェック
Definition: TnbFileName.h:515
bool IsCompressed(void) const
[確認] Compressed属性チェック
Definition: TnbFileName.h:480
CStr GetFullName(void) const
[取得] フルName名取得
Definition: TnbFileName.h:184
bool SetReadOnly(void)
[設定] ReadOnly属性設定
Definition: TnbFileName.h:555
bool MakeShortcut(LPCTSTR lpszLinkName, LPCTSTR lpszDescription, LPCTSTR lpszParameter=NULL) const
[作成] ショートカット作成.
Definition: TnbFileName.h:809
CStr GetFileTitle(void) const
[取得] ファイルタイトル取得
Definition: TnbFileName.h:224
bool IsHidden(void) const
[確認] Hidden属性チェック
Definition: TnbFileName.h:494
CFileName(LPCTSTR lpszName, bool dummy)
代入コンストラクタ.
Definition: TnbFileName.h:86
DWORD GetBytesOfCluster(void) const
[取得] クラスタサイズ取得.
Definition: TnbFileName.h:356
CStr GetFullShortName(void) const
[取得] FullShortName名取得
Definition: TnbFileName.h:193
bool IsTemporary(void) const
[確認] Temporary属性チェック
Definition: TnbFileName.h:501
CStr InsertAtEndOfName(LPCTSTR lpsz, LPCTSTR lpszExt=NULL) const
[取得] ファイル名末文字列追加.
Definition: TnbFileName.h:430
CStr GetShortName(void) const
[取得] ShortName名取得
Definition: TnbFileName.h:239
bool MakeDirectory(void)
[作成] フォルダ作成.
Definition: TnbFileName.h:628
bool Rename(LPCTSTR lpszNew, bool boIsAllowUndo=false, bool boIsSilent=true)
[操作] リネーム.
Definition: TnbFileName.h:667
CStr GetFileName(void) const
[取得] ファイル名取得
Definition: TnbFileName.h:209
void Set(LPCTSTR lpszName, const WIN32_FILE_ATTRIBUTE_DATA &tFileAttr)
[設定] 代入
Definition: TnbFileName.h:129
CFileName(LPCTSTR lpszName)
代入コンストラクタ
Definition: TnbFileName.h:75
LONGLONG GetSize(void) const
[取得] ファイルサイズ取得
Definition: TnbFileName.h:285
bool SetHidden(void)
[設定] Hidden属性設定
Definition: TnbFileName.h:562
CFileName(void)
コンストラクタ
Definition: TnbFileName.h:66
DWORD SetTime(const CFileTimeEx &timeCreation, const CFileTimeEx &timeLastAccess, const CFileTimeEx &timeLastWrite)
[設定] ファイル日付設定
Definition: TnbFileName.h:579
bool IsSystem(void) const
[確認] System属性チェック
Definition: TnbFileName.h:487
CStrVector GetFiles(LPCTSTR lpszOpt=_T("\\*.*"))
[作成] ファイル一覧作成
Definition: TnbFileName.h:596
bool GetFindData(LPWIN32_FIND_DATA P) const
[取得] ファイル情報取得
Definition: TnbFileName.h:403
LONGLONG GetSizeOnDisk(void) const
[取得] ディスク上のサイズ取得
Definition: TnbFileName.h:305
CFileTimeEx GetLastWriteTime(void) const
[取得] 最終書込み日時取得
Definition: TnbFileName.h:521
bool Remove(bool boIsAllowUndo=false, bool boIsSilent=true)
[操作] 削除.
Definition: TnbFileName.h:692
bool IsSameFile(LPCTSTR lpszName) const
[確認] 比較.
Definition: TnbFileName.h:164
CFileName & operator=(LPCTSTR lpszName)
[設定] 代入オペレーション
Definition: TnbFileName.h:98
bool GetAttributeData(LPWIN32_FILE_ATTRIBUTE_DATA P) const
[取得] ファイル情報取得
Definition: TnbFileName.h:386
bool IsNormal(void) const
[確認] Normal属性チェック
Definition: TnbFileName.h:508
bool ResolveShortcut(CStr &_description, HWND hWnd=NULL)
[設定] ショートカット解決.
Definition: TnbFileName.h:891
ファイルタイム管理クラス
Definition: TnbTime.h:45
ファイル書き込みクラス
Definition: TnbFile.h:475
bool Open(LPCTSTR lpszName, bool boIsShare=true, bool boIsBottom=true)
[操作] オープン.
Definition: TnbFile.h:516
void SetTime(const CFileTimeEx &timeCreation, const CFileTimeEx &timeLastAccess, const CFileTimeEx &timeLastWrite)
[設定] ファイル日付設定
Definition: TnbFile.h:599
INT_PTR ReverseFind(TYP t) const
[確認] 検索(後ろから)
Definition: TnbStr.h:575
INT_PTR ReverseFindOneOf(const TYP *lpsz) const
[確認] 検索(後ろから)
Definition: TnbStr.h:621
CStrT Left(size_t iSize) const
[作成] 範囲取得.
Definition: TnbStr.h:801
void ReleaseBuffer(void)
[操作] 割り当てたバッファを開放.
Definition: TnbStr.h:954
static CStrT Fmt(const TCHAR *lpszFormat,...)
[作成] 書式付き文字列作成
Definition: TnbStr.h:1206
INT_PTR Find(TYP t, INDEX iFromIndex=0) const
[確認] 検索.
Definition: TnbStr.h:540
CStrT & TrimRight(TYP t=' ')
[処理] 末尾から文字をトリム.
Definition: TnbStr.h:990
void Empty(void)
[削除] 空化
Definition: TnbStr.h:197
int Replace(TYP tOld, TYP tNew)
[処理] 文字置換.
Definition: TnbStr.h:1038
void Format(const TYP *lpszFormat,...)
[代入] 書式付き文字列代入.
Definition: TnbStr.h:359
int CompareNoCase(const TYP *lpszSubject) const
[確認] 文字列比較(大小区別無く比較)
Definition: TnbStr.h:678
CStrT Mid(INDEX iOffset, size_t iSize=INVALID_SIZE) const
[作成] 範囲取得.
Definition: TnbStr.h:766
TYP * GetBuffer(size_t iLength=0)
[操作] 書き込みバッファ要求.
Definition: TnbStr.h:914
virtual INDEX Add(const TYP &t)
[追加] 要素一つ追加.
Definition: TnbVector.h:383
TNB::CStrT< WCHAR > CUnicode
UNICODE文字列クラス
Definition: TnbStr.h:1771
void Copy(LPSTR _dst, LPCSTR src)
[複製] 文字列コピー(ASCII/SJIS用)
Definition: TnbStrLib.h:89
CStr GetProcessPath(void)
[取得] プロセスのパス取得.
Definition: TnbStrEx.h:57
TNB Library
Definition: TnbDoxyTitle.txt:2