Rev 8953 | Rev 9505 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8953 | Rev 9471 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | 5 | ||
6 | #ifndef INCLUDE_FILESYSTEM_H |
6 | #ifndef INCLUDE_FILESYSTEM_H |
7 | #include "../lib/fs.h" |
7 | #include "../lib/fs.h" |
Line -... | Line 8... | ||
- | 8 | #endif |
|
- | 9 | ||
- | 10 | enum { |
|
- | 11 | FILE_DEFAULT=0, |
|
- | 12 | FILE_EXISTS, |
|
- | 13 | FILE_REPLACE, |
|
- | 14 | FILE_SKIP, |
|
- | 15 | }; |
|
- | 16 | ||
8 | #endif |
17 | int copy_state = FILE_DEFAULT; |
9 | 18 | ||
10 | :int copyf(dword from1, in1) |
19 | :int copyf(dword from1, in1) |
11 | { |
20 | { |
- | 21 | dword error; |
|
Line 12... | Line 22... | ||
12 | dword error; |
22 | BDVK CopyFile_atr1; |
13 | BDVK CopyFile_atr1; |
23 | copy_state = FILE_DEFAULT; |
14 | 24 | ||
15 | if (!from1) || (!in1) |
25 | if (!from1) || (!in1) |
Line 24... | Line 34... | ||
24 | } |
34 | } |
25 | if (dir_exists(from1)) |
35 | if (dir_exists(from1)) |
26 | return CopyFolder(from1, in1); |
36 | return CopyFolder(from1, in1); |
27 | else |
37 | else |
28 | { |
38 | { |
- | 39 | while(1) |
|
- | 40 | { |
|
29 | Operation_Draw_Progress(from1+strrchr(from1, '/')); |
41 | Operation_Draw_Progress(from1+strrchr(from1, '/')); |
- | 42 | if (copy_state == FILE_DEFAULT) || (copy_state == FILE_REPLACE) |
|
- | 43 | { |
|
30 | return CopyFile(from1, in1); |
44 | error = CopyFile(from1, in1); |
- | 45 | if (error != 222) |
|
- | 46 | { |
|
- | 47 | return error; |
|
- | 48 | } |
|
- | 49 | } |
|
- | 50 | if (copy_state == FILE_SKIP) |
|
- | 51 | { |
|
- | 52 | return 0; |
|
- | 53 | } |
|
- | 54 | } |
|
31 | } |
55 | } |
32 | } |
56 | } |
Line 33... | Line 57... | ||
33 | 57 | ||
34 | :int CopyFile(dword copy_from3, copy_in3) |
58 | :int CopyFile(dword copy_from3, copy_in3) |
Line 40... | Line 64... | ||
40 | { |
64 | { |
41 | debugln("Error: CopyFile->GetFileInfo"); |
65 | debugln("Error: CopyFile->GetFileInfo"); |
42 | } |
66 | } |
43 | else |
67 | else |
44 | { |
68 | { |
- | 69 | if (file_exists(copy_in3)) && (copy_state != FILE_REPLACE) |
|
- | 70 | { |
|
- | 71 | copy_state = FILE_EXISTS; |
|
- | 72 | return 222; |
|
- | 73 | } |
|
45 | if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes |
74 | if (GetFreeRAM()-1024*1024 < CopyFile_atr.sizelo) //GetFreeRam-1Mb and convert to bytes |
46 | { |
75 | { |
47 | if (error = CopyFileByBlocks(CopyFile_atr.sizelo, copy_from3, copy_in3)) |
76 | if (error = CopyFileByBlocks(CopyFile_atr.sizelo, copy_from3, copy_in3)) |
48 | debugln("Error: CopyFile->CopyFileByBlocks"); |
77 | debugln("Error: CopyFile->CopyFileByBlocks"); |
49 | } |
78 | } |
Line 77... | Line 106... | ||
77 | return error; |
106 | return error; |
78 | } |
107 | } |
Line 79... | Line 108... | ||
79 | 108 | ||
80 | for (i=0; i |
109 | for (i=0; i |
- | 110 | { |
|
81 | { |
111 | copy_state = FILE_DEFAULT; |
82 | filename = i*304+dirbuf+72; |
112 | filename = i*304+dirbuf+72; |
83 | sprintf(#copy_from2,"%s/%s",from2,filename); |
113 | sprintf(#copy_from2,"%s/%s",from2,filename); |
Line 84... | Line 114... | ||
84 | sprintf(#copy_in2,"%s/%s",in2,filename); |
114 | sprintf(#copy_in2,"%s/%s",in2,filename); |
Line 88... | Line 118... | ||
88 | if ( (!strncmp(filename, ".",1)) || (!strncmp(filename, "..",2)) ) continue; |
118 | if ( (!strncmp(filename, ".",1)) || (!strncmp(filename, "..",2)) ) continue; |
89 | CopyFolder(#copy_from2, #copy_in2); |
119 | CopyFolder(#copy_from2, #copy_in2); |
90 | } |
120 | } |
91 | else |
121 | else |
92 | { |
122 | { |
- | 123 | while(1) |
|
- | 124 | { |
|
93 | Operation_Draw_Progress(filename+strrchr(filename, '/')); |
125 | Operation_Draw_Progress(filename+strrchr(filename, '/')); |
- | 126 | if (copy_state == FILE_DEFAULT) || (copy_state == FILE_REPLACE) |
|
- | 127 | { |
|
94 | if (error=CopyFile(#copy_from2, #copy_in2)) |
128 | error = CopyFile(#copy_from2, #copy_in2); |
- | 129 | if (error != 222) |
|
- | 130 | { |
|
- | 131 | if (error) |
|
95 | { |
132 | { |
96 | if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all |
133 | if (fabs(error)==8) { debugln("Stop copying."); break;} //TODO: may be need grobal var like stop_all |
97 | error=CopyFile(#copy_from2, #copy_in2); // #2 :) |
134 | error=CopyFile(#copy_from2, #copy_in2); // #2 :) |
98 | } |
135 | } |
- | 136 | break; |
|
- | 137 | } |
|
- | 138 | } |
|
- | 139 | if (copy_state == FILE_SKIP) |
|
- | 140 | { |
|
- | 141 | copy_state = FILE_DEFAULT; |
|
- | 142 | break; |
|
- | 143 | } |
|
- | 144 | } |
|
99 | } |
145 | } |
100 | } |
146 | } |
101 | free(dirbuf); |
147 | free(dirbuf); |
102 | return error; |
148 | return error; |
103 | } |
149 | } |