Develop and Download Open Source Software

Browse CVS Repository

Contents of /tombo/Tombo/Src/MemoInfo.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Wed Nov 3 17:26:44 2004 UTC (19 years, 5 months ago) by hirami
Branch: MAIN
CVS Tags: Tombo_2_0a3, Tombo_2_0a2, Tombo_2_0a1, Tombo_1_17_1, B191, B192, B193, B194, B196, B197, B198, B199, B200, B201, B202, B203, B205, B206, B207, B208, B183, B181, B180, B187, B186, B184, B189, B188, B213, B212, B211, B217, B216, B215, B214, B219, B218, Tombo_2_0b2, Tombo_2_0b3, Tombo_2_0b1, Tombo_2_0b4, B228, B229, B226, B227, B224, B225, B222, B223, B220, B221, B172, B173, B171, Tombo_1_13, SNAPSHOT20051220, B231, B230, Tombo_1_15, Tombo_1_14, Tombo_1_17, Tombo_1_16, B177, B174, B175, B178, B179, B169, B168, B165, SNAPSHOT_20041121, B166, HEAD
Branch point for: Tombo_1_17_1_branch
Changes since 1.2: +1 -1 lines
File MIME type: text/x-c++src
* DEV: save for safe file name notes support.

1 #include <windows.h>
2 #include <tchar.h>
3 #include "Tombo.h"
4 #include "TString.h"
5 #include "File.h"
6 #include "MemoInfo.h"
7
8 #define VERSION_INFO 1
9 #define TDT_FILE_EXT TEXT(".tdt")
10
11 BOOL MemoInfo::WriteInfo(LPCTSTR pMemoPath, DWORD nPos)
12 {
13 BYTE cVer = VERSION_INFO;
14
15 TString sFileName;
16 if (!sFileName.Join(pTopDir, TEXT("\\"), pMemoPath, TDT_FILE_EXT)) return FALSE;
17
18 File fInfo;
19 if (!fInfo.Open(sFileName.Get(), GENERIC_WRITE, 0, CREATE_ALWAYS)) {
20 return FALSE;
21 }
22 if (!fInfo.Write((LPBYTE)&cVer, sizeof(cVer)) ||
23 !fInfo.Write((LPBYTE)&nPos, sizeof(nPos))) {
24 return FALSE;
25 }
26 fInfo.Close();
27 return TRUE;
28 }
29
30 BOOL MemoInfo::ReadInfo(LPCTSTR pMemoPath, LPDWORD pPos)
31 {
32 BYTE cVer;
33
34 TString sFileName;
35 if (!sFileName.Join(pTopDir, TEXT("\\"), pMemoPath, TDT_FILE_EXT)) return FALSE;
36
37 File fInfo;
38 if (!fInfo.Open(sFileName.Get(), GENERIC_READ, 0, OPEN_EXISTING)) {
39 return FALSE;
40 }
41 DWORD r1, r2;
42 r1 = sizeof(cVer);
43 r2 = sizeof(DWORD);
44 if (!fInfo.Read((LPBYTE)&cVer, &r1) ||
45 !fInfo.Read((LPBYTE)pPos, &r2)) {
46 return FALSE;
47 }
48 if (cVer != VERSION_INFO) {
49 *pPos = 0;
50 }
51 fInfo.Close();
52 return TRUE;
53 }
54
55 BOOL MemoInfo::DeleteInfo(LPCTSTR pMemoPath)
56 {
57 TString sFileName;
58 if (!sFileName.Join(pTopDir, TEXT("\\"), pMemoPath, TDT_FILE_EXT)) return FALSE;
59 return DeleteFile(sFileName.Get());
60 }
61
62 BOOL MemoInfo::RenameInfo(LPCTSTR pOld, LPCTSTR pNew)
63 {
64 TString sOldFileName;
65 TString sNewFileName;
66 if (!sOldFileName.Join(pOld, TDT_FILE_EXT) || !sNewFileName.Join(pNew, TDT_FILE_EXT)) return FALSE;
67 DeleteFile(sNewFileName.Get());
68 return MoveFile(sOldFileName.Get(), sNewFileName.Get());
69 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26