OSDN Git Service

Version 3.00
[vbslib/main.git] / vbslib / vbslib300 / MergeLib.vbs
1 Option Explicit \r
2 \r
3 ' vbslib  ver3.00  Sep.22, 2009\r
4 ' Copyright (c) 2008-2009, T's-Neko at Sage Plaisir 21 (Japan)\r
5 ' All rights reserved. Based on 3-clause BSD license.\r
6 \r
7 Dim  g_SrcPath\r
8 Dim  g_MergeLibPath\r
9      g_MergeLibPath = g_SrcPath\r
10 \r
11 \r
12 \r
13 \r
14  \r
15 '********************************************************************************\r
16 '  <<< [RunMergePrompt] >>> \r
17 '********************************************************************************\r
18 Sub  RunMergePrompt( Pathes, Opt )\r
19   Dim  status : Set status = new Merge_Status : ErrCheck\r
20   Dim  i, src_path, dst_path\r
21   Dim  base, ext, new_path\r
22 \r
23   If not exist( Opt.m_DiffPath ) Then  Err.Raise 1,,"Diff \82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81F"+Opt.m_DiffPath\r
24   If not exist( Opt.m_EditorPath ) Then  Err.Raise 1,,"\83G\83f\83B\83^\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81F"+Opt.m_EditorPath\r
25   For i=0 To UBound( Pathes )\r
26     If IsEmpty( Pathes(i) ) Then  Err.Raise 1,,"Pathes("&i&") \82ª\90Ý\92è\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B"\r
27     If not exist( Pathes(i) ) Then  Err.Raise 1,,"Pathes("&i&") = " + Pathes(i) + " \82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ\81B"\r
28   Next\r
29 \r
30   base = g_fs.GetBaseName( Pathes(0) )\r
31   ext = g_fs.GetExtensionName( Pathes(0) )\r
32   If IsEmpty( Opt.m_NewPath ) Then  new_path = "New\" + base + "." + ext _\r
33   Else  new_path = Opt.m_NewPath\r
34 \r
35   Do\r
36 \r
37     '//== 1 files\r
38     If UBound( Pathes ) = 0 Then\r
39       Redim  sub_pathes(0)\r
40 \r
41       If exist( new_path ) Then\r
42         Do\r
43           echo "-------------------------------------------"\r
44           echo  base + "." + ext + " \82Ì\83R\83s\81[\82Í\8a®\97¹\82µ\82Ü\82µ\82½\81B"\r
45           echo  "5. \83R\83s\81[\8dÏ\82Ý\82ð\8aJ\82­"\r
46           echo  "6. \83R\83s\81[\8dÏ\82Ý\83t\83H\83\8b\83_\82ð\8aJ\82­"\r
47           echo  "8. \91O\82Ì\83X\83e\83b\83v\82Ö"\r
48           echo  "9. \8fI\97¹"\r
49           i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
50           echo "-------------------------------------------"\r
51           If i = 9 Then  Exit Sub\r
52           If i = 8 Then\r
53             i = input( "\91O\83X\83e\83b\83v\82É\96ß\82é\82½\82ß\81A" + new_path + " \82ð\8dí\8f\9c\82µ\82Ü\82·\81B[Y/N]" )\r
54             If i = "y" or i = "Y" Then  del new_path : Exit Do\r
55           End If\r
56           If i = 5 Then  OpenMergePath  Opt.m_EditorPath, new_path\r
57           If i = 6 Then  OpenMergePath  Opt.m_EditorPath, g_fs.GetParentFolderName( new_path )\r
58         Loop\r
59       Else\r
60         sub_pathes(0) = Pathes(0)\r
61         status.m_EditingNum = -1\r
62         status.m_StepIDFilePath = Empty\r
63         RunMergePromptSub  sub_pathes, status, Opt\r
64         If status.m_bExit Then  Exit Sub\r
65         If status.m_CopyNum = 1 Then\r
66           src_path = Pathes(0) : dst_path = new_path\r
67           echo  "copy """ + src_path + """, """ + dst_path + """"\r
68           copy  src_path, dst_path\r
69         End If\r
70       End If\r
71 \r
72 \r
73     '//== 2 files\r
74     ElseIf UBound( Pathes ) = 1 Then\r
75 \r
76       status.m_CurrentStep = 1\r
77       status.m_LastStep = 1\r
78 \r
79       Do\r
80 \r
81         '//== 2 files Step A\r
82         If not exist( new_path ) and _\r
83            not exist( "Editing\" + base + "(1)M." + ext ) Then\r
84           Redim  sub_pathes(1)\r
85           sub_pathes(0) = Pathes(0)\r
86           sub_pathes(1) = Pathes(1)\r
87           status.m_EditingNum = 0\r
88           status.m_StepIDFilePath = Empty\r
89 \r
90 \r
91           RunMergePromptSub  sub_pathes, status, Opt\r
92           If status.m_bExit Then  Exit Sub\r
93 \r
94 \r
95           Select Case  status.m_CopyNum\r
96             Case 1\r
97               src_path = Pathes(0) : dst_path = "Editing\" + base + "(1)M." + ext\r
98               echo  "copy """ + src_path + """, """ + dst_path + """"\r
99               copy  src_path, dst_path\r
100             Case 2\r
101               src_path = Pathes(1) : dst_path = "Editing\" + base + "(1)M." + ext\r
102               echo  "copy """ + src_path + """, """ + dst_path + """"\r
103               copy  src_path, dst_path\r
104           End Select\r
105 \r
106 \r
107         '//== 2 files Step B\r
108         ElseIf not exist( new_path ) Then\r
109           Redim  sub_pathes(2)\r
110           sub_pathes(0) = Pathes(0)\r
111           sub_pathes(1) = "Editing\" + base + "(1)M." + ext\r
112           sub_pathes(2) = Pathes(1)\r
113           status.m_EditingNum = 2\r
114           status.m_StepIDFilePath = sub_pathes(1)\r
115 \r
116 \r
117           RunMergePromptSub  sub_pathes, status, Opt\r
118           If status.m_bExit Then  Exit Sub\r
119 \r
120 \r
121           If exist( sub_pathes(1) ) Then\r
122             src_path = sub_pathes(1) : dst_path = new_path\r
123             echo  "copy """ + src_path + """, """ + dst_path + """"\r
124             copy  src_path, dst_path\r
125             Exit Do\r
126           End If\r
127 \r
128 \r
129         '//== 2 files complated\r
130         Else\r
131           Do\r
132             echo "-------------------------------------------"\r
133             echo  base + "." + ext + " \82Ì\83}\81[\83W\82Í\8a®\97¹\82µ\82Ü\82µ\82½\81B"\r
134             echo  "5. \83}\81[\83W\8dÏ\82Ý\82ð\8aJ\82­"\r
135             echo  "6. \83}\81[\83W\8dÏ\82Ý\83t\83H\83\8b\83_\82ð\8aJ\82­"\r
136             If not IsEmpty( Opt.m_SyncPathes ) Then _\r
137               echo  "7. \93¯\82\96¼\91O\82Ì\83t\83@\83C\83\8b\82ð\82·\82×\82Ä\83}\81[\83W\8dÏ\82Ý\82É\8dX\90V\82·\82é"\r
138             echo  "8. \91O\82Ì\83X\83e\83b\83v\82Ö"\r
139             echo  "9. \8fI\97¹"\r
140             i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
141             echo "-------------------------------------------"\r
142             If i = 9 Then  Exit Sub\r
143             If i = 8 Then\r
144               i = input( "\91O\83X\83e\83b\83v\82É\96ß\82é\82½\82ß\81A" + new_path + " \82ð\8dí\8f\9c\82µ\82Ü\82·\81B[Y/N]" )\r
145               If i = "y" or i = "Y" Then  del new_path : Exit Do\r
146             End If\r
147             If i = 5 Then  OpenMergePath  Opt.m_EditorPath, new_path\r
148             If i = 6 Then  OpenMergePath  Opt.m_EditorPath, g_fs.GetParentFolderName( new_path )\r
149             If i = 7 and (not IsEmpty(Opt.m_SyncPathes)) Then  RunMergeUpdate  new_path, Pathes, Opt\r
150           Loop\r
151         End If\r
152       Loop\r
153 \r
154 \r
155     '//== N files\r
156     Else\r
157 \r
158       status.m_LastStep = UBound( Pathes ) - 1\r
159 \r
160 \r
161       '//== N files merged\r
162       If exist( new_path ) Then\r
163         Do\r
164           echo "-------------------------------------------"\r
165           echo  base + "." + ext + " \82Ì\83}\81[\83W\82Í\8a®\97¹\82µ\82Ü\82µ\82½\81B"\r
166           echo  "5. \83}\81[\83W\8dÏ\82Ý\82ð\8aJ\82­"\r
167           echo  "6. \83}\81[\83W\8dÏ\82Ý\83t\83H\83\8b\83_\82ð\8aJ\82­"\r
168           If not IsEmpty( Opt.m_SyncPathes ) Then _\r
169             echo  "7. \82·\82×\82Ä\82Ì\83t\83@\83C\83\8b\82ð\83}\81[\83W\8dÏ\82Ý\82É\8dX\90V\82·\82é"\r
170           echo  "8. \91O\82Ì\83X\83e\83b\83v\82Ö"\r
171           echo  "9. \8fI\97¹"\r
172           i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
173           echo "-------------------------------------------"\r
174           If i = 9 Then  Exit Sub\r
175           If i = 8 Then\r
176             i = input( "\91O\83X\83e\83b\83v\82É\96ß\82é\82½\82ß\81A" + new_path + " \82ð\8dí\8f\9c\82µ\82Ü\82·\81B[Y/N]" )\r
177             If i = "y" or i = "Y" Then  del new_path : Exit Do\r
178           End If\r
179           If i = 5 Then  OpenMergePath  Opt.m_EditorPath, new_path\r
180           If i = 6 Then  OpenMergePath  Opt.m_EditorPath, g_fs.GetParentFolderName( new_path )\r
181           If i = 7 and (not IsEmpty(Opt.m_SyncPathes)) Then  RunMergeUpdate  new_path, Pathes, Opt\r
182         Loop\r
183         del  new_path\r
184       End If\r
185 \r
186 \r
187       '//== Count step by counting file exists\r
188       status.m_StepIDFilePath = Empty\r
189       status.m_EditingNum = 0\r
190       For i = UBound( Pathes ) To 1 Step -1\r
191         If exist( "Editing\" + base + "(" & i & ")L." + ext ) Then\r
192           status.m_StepIDFilePath = "Editing\" + base + "(" & i & ")L." + ext\r
193           status.m_EditingNum = 1 : Exit For\r
194         ElseIf exist( "Editing\" + base + "(" & i & ")M." + ext ) Then\r
195           status.m_StepIDFilePath = "Editing\" + base + "(" & i & ")M." + ext\r
196           status.m_EditingNum = 2 : Exit For\r
197         ElseIf exist( "Editing\" + base + "(" & i & ")R." + ext ) Then\r
198           status.m_StepIDFilePath = "Editing\" + base + "(" & i & ")R." + ext\r
199           status.m_EditingNum = 3 : Exit For\r
200         ElseIf exist( "Editing\" + base + "(" & i & ")." + ext ) Then\r
201           status.m_StepIDFilePath = "Editing\" + base + "(" & i & ")." + ext\r
202           status.m_EditingNum = 0 : Exit For\r
203        End If\r
204       Next\r
205       If i = 0 Then  status.m_CurrentStep = 1 _\r
206       Else           status.m_CurrentStep = i\r
207 \r
208 \r
209       '//== N files Step A\r
210       Redim  sub_pathes(2)\r
211       If status.m_EditingNum = 0 Then\r
212         If status.m_CurrentStep = 1 Then\r
213           sub_pathes(0) = Pathes(1)\r
214           sub_pathes(1) = Pathes(0)\r
215           sub_pathes(2) = Pathes(2)\r
216         Else\r
217           sub_pathes(0) = "Editing\" + base + _\r
218             "(" & status.m_CurrentStep & ")." + ext\r
219           sub_pathes(1) = Pathes(0)\r
220           sub_pathes(2) = Pathes( status.m_CurrentStep + 1 )\r
221         End If\r
222 \r
223 \r
224         RunMergePromptSub  sub_pathes, status, Opt\r
225         If status.m_bExit Then  Exit Sub\r
226 \r
227 \r
228         Select Case  status.m_CopyNum\r
229           Case 1\r
230             src_path = sub_pathes(0) : dst_path = "Editing\" + base + "(" & status.m_CurrentStep & ")L." + ext\r
231             echo  "copy """ + src_path + """, """ + dst_path + """"\r
232             copy  src_path, dst_path\r
233           Case 2\r
234             src_path = sub_pathes(1) : dst_path = "Editing\" + base + "(" & status.m_CurrentStep & ")M." + ext\r
235             echo  "copy """ + src_path + """, """ + dst_path + """"\r
236             copy  src_path, dst_path\r
237           Case 3\r
238             src_path = sub_pathes(2) : dst_path = "Editing\" + base + "(" & status.m_CurrentStep & ")R." + ext\r
239             echo  "copy """ + src_path + """, """ + dst_path + """"\r
240             copy  src_path, dst_path\r
241         End Select\r
242 \r
243 \r
244       '//== N files Step B\r
245       Else\r
246         If status.m_EditingNum = 1 Then\r
247           sub_pathes(0) = "Editing\" + base + "(" & status.m_CurrentStep & ")L." + ext\r
248         ElseIf status.m_CurrentStep = 1 Then\r
249           sub_pathes(0) = Pathes(1)\r
250         Else\r
251           sub_pathes(0) = "Editing\" + base + "(" & status.m_CurrentStep & ")." + ext\r
252         End If\r
253         If status.m_EditingNum = 2 Then\r
254           sub_pathes(1) = "Editing\" + base + "(" & status.m_CurrentStep & ")M." + ext\r
255         Else\r
256           sub_pathes(1) = Pathes(0)\r
257         End If\r
258         If status.m_EditingNum = 3 Then\r
259           sub_pathes(2) = "Editing\" + base + "(" & status.m_CurrentStep & ")R." + ext\r
260         Else\r
261           sub_pathes(2) = Pathes( status.m_CurrentStep + 1 )\r
262         End If\r
263 \r
264 \r
265         RunMergePromptSub  sub_pathes, status, Opt\r
266         If status.m_bExit Then  Exit Sub\r
267 \r
268 \r
269         If status.m_CopyNum <> 0 Then\r
270           If status.m_CurrentStep = status.m_LastStep Then\r
271             Select Case  status.m_EditingNum\r
272               Case 1\r
273                 src_path = "Editing\" + base + "(" & status.m_CurrentStep & ")L." + ext : dst_path = new_path\r
274                 echo  "copy """ + src_path + """, """ + dst_path + """"\r
275                 copy  src_path, dst_path\r
276               Case 2\r
277                 src_path = "Editing\" + base + "(" & status.m_CurrentStep & ")M." + ext : dst_path = new_path\r
278                 echo  "copy """ + src_path + """, """ + dst_path + """"\r
279                 copy  src_path, dst_path\r
280               Case 3\r
281                 src_path = "Editing\" + base + "(" & status.m_CurrentStep & ")R." + ext : dst_path = new_path\r
282                 echo  "copy """ + src_path + """, """ + dst_path + """"\r
283                 copy  src_path, dst_path\r
284             End Select\r
285           Else\r
286             Select Case  status.m_EditingNum\r
287               Case 1\r
288                 src_path = "Editing\" + base + "(" & status.m_CurrentStep & ")L." + ext\r
289                 dst_path = "Editing\" + base + "(" & (status.m_CurrentStep+1) & ")." + ext\r
290                 echo  "copy """ + src_path + """, """ + dst_path + """"\r
291                 copy  src_path, dst_path\r
292               Case 2\r
293                 src_path = "Editing\" + base + "(" & status.m_CurrentStep & ")M." + ext\r
294                 dst_path = "Editing\" + base + "(" & (status.m_CurrentStep+1) & ")." + ext\r
295                 echo  "copy """ + src_path + """, """ + dst_path + """"\r
296                 copy  src_path, dst_path\r
297               Case 3\r
298                 src_path = "Editing\" + base + "(" & status.m_CurrentStep & ")R." + ext\r
299                 dst_path = "Editing\" + base + "(" & (status.m_CurrentStep+1) & ")." + ext\r
300                 echo  "copy """ + src_path + """, """ + dst_path + """"\r
301                 copy  src_path, dst_path\r
302             End Select\r
303           End If\r
304         End If\r
305       End IF\r
306     End IF\r
307   Loop\r
308 End Sub\r
309 \r
310 \r
311  \r
312 '********************************************************************************\r
313 '  <<< [RunMergePromptSub] >>> \r
314 '********************************************************************************\r
315 Sub  RunMergePromptSub( SubPathes, Status, Opt )\r
316   Dim  i, s, i0,i1,i2\r
317 \r
318   Status.m_CopyNum = 0\r
319 \r
320   If UBound( SubPathes ) > 1 Then\r
321     Select Case  Status.m_EditingNum\r
322       Case 1    : i0=0 : i1=2 : i2=1\r
323       Case 3    : i0=1 : i1=0 : i2=2\r
324       Case Else : i0=0 : i1=1 : i2=2\r
325     End Select\r
326   Else\r
327     i0=0 : i1=1\r
328   End If\r
329 \r
330  Do\r
331   echo "-------------------------------------------"\r
332   Select Case  Status.m_EditingNum\r
333     Case -1: echo "\83t\83@\83C\83\8b\82ð\83R\83s\81[\82µ\82Ä\82­\82¾\82³\82¢"\r
334     Case 0 : echo "\95Ò\8fW\82ª\8aJ\8en\82Å\82«\82é\82æ\82¤\82É\83R\83s\81[\82·\82é\83t\83@\83C\83\8b\82ð\91I\91ð\82µ\82Ä\82­\82¾\82³\82¢"\r
335     Case 1 : echo "\8d\82Æ\92\86\82Ì\8d·\95ª\82ð\81A\89E\82Ì\83t\83@\83C\83\8b\82É\94½\89f\82³\82¹\82Ä\82­\82¾\82³\82¢"\r
336     Case 2 : echo "\92\86\89\9b\82Ì\83t\83@\83C\83\8b\82ð\95Ò\8fW\82µ\82Ä\82­\82¾\82³\82¢"\r
337     Case 3 : echo "\89E\82Æ\92\86\82Ì\8d·\95ª\82ð\81A\8d\82Ì\83t\83@\83C\83\8b\82É\94½\89f\82³\82¹\82Ä\82­\82¾\82³\82¢"\r
338   End Select\r
339   If Status.m_EditingNum <> -1 Then\r
340     If Status.m_EditingNum = 0 Then  i = "A"  Else  i = "B"\r
341     echo "\83}\81[\83W\81E\83X\83e\83b\83v " & Status.m_CurrentStep & i & "/" & Status.m_LastStep & "B"\r
342   End IF\r
343 \r
344   If UBound( SubPathes ) = 0 Then\r
345     echo "4. \8aJ\82­: "+SubPathes(0)\r
346   ElseIf UBound( SubPathes ) = 1 Then\r
347     echo "1. Diff \83c\81[\83\8b\8bN\93®"\r
348     echo "4. \8d\82ð\8aJ\82­: "+SubPathes(0)\r
349     echo "6. \89E\82ð\8aJ\82­: "+SubPathes(1)\r
350   Else\r
351     echo "1. Diff \83c\81[\83\8b\8bN\93®"\r
352 \r
353     If i0=1 Then  s="(old)"  Else  s=""\r
354     If Status.m_EditingNum=1 Then s="(edit)"\r
355     echo "4. \8d\82ð\8aJ\82­"+s+": "+SubPathes(i0)\r
356 \r
357     If i1=1 Then  s="(old)"  Else  s=""\r
358     If Status.m_EditingNum=2 Then s="(edit)"\r
359     echo "5. \92\86\82ð\8aJ\82­"+s+": "+SubPathes(i1)\r
360 \r
361     If i2=1 Then  s="(old)"  Else  s=""\r
362     If Status.m_EditingNum=3 Then s="(edit)"\r
363     echo "6. \89E\82ð\8aJ\82­"+s+": "+SubPathes(i2)\r
364   End If\r
365   Select Case  Status.m_EditingNum\r
366     Case -1: echo "7. New \83t\83H\83\8b\83_\82Ö\83R\83s\81["\r
367     Case 0 : echo "7. Editing \83t\83H\83\8b\83_\82Ö\83R\83s\81[\81i\8e\9f\82Ì\83X\83e\83b\83v\82Ö\81j"\r
368     Case 1 : echo "7. \8d\82Ì\95Ò\8fW\82ð\8a®\97¹\82µ\82Ä\81A\8e\9f\82Ì\83X\83e\83b\83v\82Ö"\r
369     Case 2 : echo "7. \92\86\89\9b\82Ì\95Ò\8fW\82ð\8a®\97¹\82µ\82Ä\81A\8e\9f\82Ì\83X\83e\83b\83v\82Ö"\r
370     Case 3 : echo "7. \89E\82Ì\95Ò\8fW\82ð\8a®\97¹\82µ\82Ä\81A\8e\9f\82Ì\83X\83e\83b\83v\82Ö"\r
371   End Select\r
372   If not IsEmpty( Status.m_StepIDFilePath ) Then _\r
373     echo  "8. \91O\82Ì\83X\83e\83b\83v\82Ö"\r
374   echo "9. \8fI\97¹"\r
375 \r
376   i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
377   echo "-------------------------------------------"\r
378 \r
379   Select Case  i\r
380    Case 1\r
381     If UBound( SubPathes ) > 0 Then\r
382       echo "Starting Diff tool : " + Opt.m_DiffPath\r
383       If UBound( SubPathes ) = 1 Then\r
384         g_sh.Run """"+Opt.m_DiffPath+""" """+SubPathes(i0)+""" """+SubPathes(i1)+""""\r
385       Else\r
386         g_sh.Run """"+Opt.m_DiffPath+""" """+SubPathes(i0)+""" """+SubPathes(i1)+""" """+SubPathes(i2)+""""\r
387       End If\r
388       echo "-------------------------------------------"\r
389     End If\r
390    Case 4\r
391     g_sh.Run """"+Opt.m_EditorPath+""" """+SubPathes(i0)+""""\r
392    Case 5\r
393     If UBound( SubPathes ) >= 2 Then _\r
394       g_sh.Run """"+Opt.m_EditorPath+""" """+SubPathes(i1)+""""\r
395    Case 6\r
396     If UBound( SubPathes ) = 1 Then\r
397       g_sh.Run """"+Opt.m_EditorPath+""" """+SubPathes(i1)+""""\r
398     ElseIf UBound( SubPathes ) = 2 Then\r
399       g_sh.Run """"+Opt.m_EditorPath+""" """+SubPathes(i2)+""""\r
400     End If\r
401    Case 7\r
402     If Status.m_EditingNum <> 0 Then  Status.m_CopyNum = 1 : Exit Sub\r
403     Do\r
404       echo "Editing \83t\83H\83\8b\83_\82Ö\83R\83s\81[\81i\8e\9f\82Ì\83X\83e\83b\83v\82Ö\81j"\r
405       If UBound( SubPathes ) >= 2 Then\r
406         echo "4. \8d\82ð\83R\83s\81[\82µ\82Ä\81A\92\86\82Æ\89E\82Ì\95\\8e¦\82ð\93ü\82ê\91Ö\82¦\82é"\r
407         echo "5. \92\86\82ð\83R\83s\81["\r
408         echo "6. \89E\82ð\83R\83s\81[\82µ\82Ä\81A\8d\82Æ\92\86\82Ì\95\\8e¦\82ð\93ü\82ê\91Ö\82¦\82é"\r
409       Else\r
410         echo "4. \8d\82ð\83R\83s\81[\82µ\82Ä\81A\92\86\89\9b\82É\92Ç\89Á\82·\82é"\r
411         echo "6. \89E\82ð\83R\83s\81[\82µ\82Ä\81A\92\86\89\9b\82É\92Ç\89Á\82·\82é"\r
412       End If\r
413       echo "8. \96ß\82é"\r
414       i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
415       echo "-------------------------------------------"\r
416       Select Case  i\r
417        Case 4 : Status.m_CopyNum = 1 : Exit Sub\r
418        Case 5 : If UBound( SubPathes ) >= 2 Then  Status.m_CopyNum = 2 : Exit Sub\r
419        Case 6 : If UBound( SubPathes ) >= 2 Then  Status.m_CopyNum = 3 : Exit Sub _\r
420                 Else                              Status.m_CopyNum = 2 : Exit Sub\r
421        Case 8 : Exit Do\r
422       End Select\r
423     Loop\r
424    Case 8\r
425     If not IsEmpty( Status.m_StepIDFilePath ) Then\r
426       i = input( "\91O\83X\83e\83b\83v\82É\96ß\82é\82½\82ß\81A" + Status.m_StepIDFilePath + " \82ð\8dí\8f\9c\82µ\82Ü\82·\81B[Y/N]" )\r
427       If i = "y" or i = "Y" Then  del Status.m_StepIDFilePath : Status.m_CopyNum = 0 : Exit Sub\r
428     End If\r
429    Case 9\r
430     Status.m_bExit = True : Exit Sub\r
431   End Select\r
432  Loop\r
433 End Sub\r
434 \r
435 \r
436  \r
437 '********************************************************************************\r
438 '  <<< [GetMergeStep] >>> \r
439 '********************************************************************************\r
440 Function  GetMergeStep( Pathes, Opt )\r
441   Dim  i\r
442   Dim  base, ext, new_path\r
443 \r
444   If UBound( Pathes ) = -1 Then  GetMergeStep = "Empty" : Exit Function\r
445   base = g_fs.GetBaseName( Pathes(0) )\r
446   ext = g_fs.GetExtensionName( Pathes(0) )\r
447   If IsEmpty( Opt.m_NewPath ) Then  new_path = "New\" + base + "." + ext _\r
448   Else  new_path = Opt.m_NewPath\r
449 \r
450 \r
451   If exist( new_path ) Then  GetMergeStep = "Fin" : Exit Function\r
452 \r
453 \r
454   '//== 2 files\r
455   If UBound( Pathes ) = 1 Then\r
456 \r
457     If exist( "Editing\" + base + "(1)M." + ext ) Then  GetMergeStep = "1B" : Exit Function\r
458     GetMergeStep = "1A"\r
459 \r
460 \r
461   '//== N files\r
462   Else\r
463     For i = UBound( Pathes ) To 1 Step -1\r
464       If exist( "Editing\" + base + "(" & i & ")L." + ext ) Then\r
465         GetMergeStep = i & "B" : Exit Function\r
466       ElseIf exist( "Editing\" + base + "(" & i & ")M." + ext ) Then\r
467         GetMergeStep = i & "B" : Exit Function\r
468       ElseIf exist( "Editing\" + base + "(" & i & ")R." + ext ) Then\r
469         GetMergeStep = i & "B" : Exit Function\r
470       ElseIf exist( "Editing\" + base + "(" & i & ")." + ext ) Then\r
471         GetMergeStep = i & "A" : Exit Function\r
472       End If\r
473     Next\r
474     GetMergeStep = "1A"\r
475   End If\r
476 \r
477 End Function\r
478 \r
479 \r
480 \r
481  \r
482 '********************************************************************************\r
483 '  <<< [OpenMergePath] >>> \r
484 '********************************************************************************\r
485 Sub  OpenMergePath( EditorPath, OpenPath )\r
486   echo  "Open """ + OpenPath + """"\r
487   If g_fs.FileExists( OpenPath ) Then\r
488     g_sh.Run """"+EditorPath+""" """+OpenPath+""""\r
489   ElseIf g_fs.FolderExists( OpenPath ) Then\r
490     g_sh.Run """"+OpenPath+""""\r
491   Else\r
492     Dim  path\r
493 \r
494     echo """" + OpenPath + """ \82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ"\r
495     path = OpenPath\r
496     Do\r
497       path = g_fs.GetParentFolderName( path )\r
498       If path = "" Then  Exit Sub\r
499       If g_fs.FolderExists( path ) Then\r
500          echo """" + path + """ \82ð\91ã\82í\82è\82É\8aJ\82«\82Ü\82·"\r
501         g_sh.Run """"+path+""""\r
502         Exit Sub\r
503       End If\r
504     Loop\r
505   End If\r
506 End Sub\r
507 \r
508  \r
509 '********************************************************************************\r
510 '  <<< [RunMergeUpdate] >>> \r
511 '********************************************************************************\r
512 Sub  RunMergeUpdate( NewPath, Pathes, Opt )\r
513   Dim  i,n\r
514 \r
515   n = 0\r
516   If not IsEmpty( Opt ) Then\r
517     If not IsEmpty( Opt.m_SyncPathes ) Then  n = UBound( Opt.m_SyncPathes )\r
518   End If\r
519 \r
520   ReDim  pathes2( UBound( Pathes ) + 1 + n )\r
521 \r
522   For i=0 To UBound( Pathes )\r
523     pathes2( i ) = Pathes( i )\r
524   Next\r
525   For i=0 To n\r
526     pathes2( UBound( Pathes ) + 1 + i ) = Opt.m_SyncPathes( i )\r
527   Next\r
528 \r
529   RunMergeUpdateSub  NewPath, pathes2, Opt\r
530 End Sub\r
531 \r
532 \r
533 Sub  RunMergeUpdateSub( NewPath, Pathes, Opt )\r
534   Dim  i\r
535   ReDim  b_equal( UBound( Pathes ) )\r
536 \r
537 \r
538   echo "[MergeUpdate]"\r
539 \r
540   '//=== Compare file with New file\r
541   For i = 0 To UBound( Pathes )\r
542     b_equal( i ) = fc_r( NewPath, Pathes( i ), Empty )\r
543     If not b_equal( i ) Then  echo Pathes(i)\r
544   Next\r
545 \r
546 \r
547   '//=== Run confirm prompt\r
548   i = input( "\88È\8fã\82Ì\83t\83@\83C\83\8b\82ð\8dX\90V\82µ\82Ü\82·\82© [Y/N]" )\r
549   If i <> "Y" and i <> "y" Then Exit Sub\r
550 \r
551 \r
552   '//=== Do merge update\r
553   Dim  backup_base, path, j\r
554 \r
555   For i = 0 To UBound( Pathes )\r
556     If not b_equal( i ) Then\r
557       backup_base = g_fs.GetParentFolderName( Pathes(i) )\r
558       backup_base = backup_base + "\backup\" + _\r
559                     g_fs.GetBaseName( Pathes(i) ) + " ("\r
560       For j=1 To 9999\r
561         path = backup_base & j & ")." & g_fs.GetExtensionName( Pathes(i) )\r
562         If not exist( path ) Then\r
563           copy Pathes(i), path\r
564           copy NewPath, Pathes(i)\r
565           j=0 : Exit For\r
566         End If\r
567       Next\r
568       If j<>0 Then  Err.Raise 1,,"Cannot write """ + path + """"\r
569     End If\r
570   Next\r
571 \r
572 End Sub\r
573 \r
574  \r
575 '*-------------------------------------------------------------------------*\r
576 '* \81\9f<<<< [Merge_Option] Class >>>> */ \r
577 '*-------------------------------------------------------------------------*\r
578 \r
579 \r
580 Class  Merge_Option\r
581   Public  m_EditorPath\r
582   Public  m_DiffPath\r
583   Public  m_NewPath\r
584   Public  m_SyncPathes  ' as array of string, or Empty\r
585 End Class\r
586 \r
587 \r
588 \r
589  \r
590 '*-------------------------------------------------------------------------*\r
591 '* \81\9f<<<< [Merge_Status] Class >>>> */ \r
592 '*-------------------------------------------------------------------------*\r
593 \r
594 \r
595 Class  Merge_Status\r
596   Public  m_CurrentStep\r
597   Public  m_LastStep\r
598   Public  m_CopyNum\r
599   Public  m_bExit\r
600   Public  m_EditingNum\r
601   Public  m_StepIDFilePath\r
602 End Class\r
603 \r
604 \r
605 \r
606  \r
607 '********************************************************************************\r
608 '  <<< [RunMergeRepPrompt] >>> \r
609 '********************************************************************************\r
610 Sub  RunMergeRepPrompt( OldPath, NewPath, PatchFolderPath, OldPatchStepPath, NewPatchStepPath, Opt )\r
611   Dim  src_path, dst_path\r
612   Dim  status : Set status = new MergeRep_Status : ErrCheck\r
613 \r
614   If OldPatchStepPath = g_fs.GetAbsolutePathName( OldPatchStepPath ) or _\r
615      Left( OldPatchStepPath, 2 ) = ".." Then\r
616     Err.Raise 1,,"OldPatchStepPath needs step path and not parent path : " + OldPatchStepPath\r
617   End If\r
618   If NewPatchStepPath = g_fs.GetAbsolutePathName( NewPatchStepPath ) or _\r
619      Left( NewPatchStepPath, 2 ) = ".." Then\r
620     Err.Raise 1,,"NewPatchStepPath needs step path and not parent path : " + NewPatchStepPath\r
621   End If\r
622 \r
623   status.m_PatchFolderPath = PatchFolderPath\r
624   status.m_OldPatchStepPath = OldPatchStepPath\r
625   status.m_NewPatchStepPath = NewPatchStepPath\r
626   status.m_OldPatchPath = PatchFolderPath + "\" + OldPatchStepPath\r
627 \r
628  Do\r
629   GetMergeRepStep  status\r
630 \r
631   If status.m_CurrentStep = "Fin" Then\r
632     Do\r
633       echo "-------------------------------------------"\r
634       echo  status.m_OldPatchStepPath + " \82Ì\83}\81[\83W\82Í\8a®\97¹\82µ\82Ü\82µ\82½\81B"\r
635       echo  "5. \83}\81[\83W\8dÏ\82Ý\82ð\8aJ\82­"\r
636       echo  "6. \83}\81[\83W\8dÏ\82Ý\83t\83H\83\8b\83_\82ð\8aJ\82­"\r
637       echo  "8. \91O\82Ì\83X\83e\83b\83v\82Ö"\r
638       echo  "9. \8fI\97¹"\r
639       i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
640       echo "-------------------------------------------"\r
641       If i=9 Then Exit Sub\r
642       If i=8 Then\r
643         i = input( "\91O\83X\83e\83b\83v\82É\96ß\82é\82½\82ß\81A" + status.m_NewPatchPath + " \82ð\8dí\8f\9c\82µ\82Ü\82·\81B[Y/N]" )\r
644         If i = "y" or i = "Y" Then  del status.m_NewPatchPath : Exit Do\r
645       End If\r
646       If i=5 Then  OpenMergePath  Opt.m_EditorPath, status.m_NewPatchPath\r
647       If i=6 Then  OpenMergePath  Opt.m_EditorPath, g_fs.GetParentFolderName( status.m_NewPatchPath )\r
648     Loop\r
649     GetMergeRepStep  status\r
650   End If\r
651 \r
652   echo "-------------------------------------------"\r
653   echo "\83}\81[\83W\81E\83X\83e\83b\83v " & status.m_CurrentStep & "/2"\r
654   If g_fs.FileExists( NewPath ) Then  echo "1. Diff  OldPatch, OldOrg, NewOrg"\r
655   echo "2. OldPatch \82ð\8aJ\82­: " + status.m_OldPatchPath\r
656   If status.m_CurrentStep <> "1" Then\r
657     echo "3. NewPatch \82ð\8aJ\82­: " + status.m_NewPatchPath\r
658   End If\r
659   If status.m_CurrentStep <> "1" Then\r
660     If g_fs.FileExists( status.m_NewPatchPath ) Then\r
661       echo "4. Diff  OldPatch, NewPatch, NewOrg"\r
662     End If\r
663   End If\r
664   If exist( OldPath ) Then  echo "5. OldOrg \82ð\8aJ\82­: " + OldPath _\r
665   Else                      echo "5. OldOrg \82Í\91\8dÝ\82µ\82Ü\82¹\82ñ: " + OldPath\r
666   If exist( NewPath ) Then  echo "6. NewOrg \82ð\8aJ\82­: " + NewPath _\r
667   Else                      echo "6. NewOrg \82Í\91\8dÝ\82µ\82Ü\82¹\82ñ: " + NewPath\r
668   Select Case  status.m_CurrentStep\r
669     Case "1" : echo "7. OldPatch \82ð Editing \83t\83H\83\8b\83_\82Ö\83R\83s\81[\82µ\82Ä\95Ò\8fW\8aJ\8en\81i\8e\9f\82Ì\83X\83e\83b\83v\82Ö\81j"\r
670     Case "2" : echo "7. NewPatch \82ð New \83t\83H\83\8b\83_\82Ö\83R\83s\81[\82µ\82Ä\8a®\97¹"\r
671   End Select\r
672   If status.m_CurrentStep <> "1" Then _\r
673     echo  "8. \91O\82Ì\83X\83e\83b\83v\82Ö"\r
674   echo "9. \8fI\97¹"\r
675 \r
676   i = CInt2( input("\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢\81B>") )\r
677   echo "-------------------------------------------"\r
678 \r
679   Select Case  i\r
680    Case 1 :\r
681     If g_fs.FileExists( NewPath ) Then\r
682       echo "Starting Diff tool : " + Opt.m_DiffPath\r
683       g_sh.Run """"+Opt.m_DiffPath+""" """+status.m_OldPatchPath+""" """+OldPath+""" """+NewPath+""""\r
684     End If\r
685    Case 2 : OpenMergePath  Opt.m_EditorPath, status.m_OldPatchPath\r
686    Case 3 : If status.m_CurrentStep <> "1" Then _\r
687             OpenMergePath  Opt.m_EditorPath, status.m_NewPatchPath\r
688 \r
689    Case 4:\r
690     If status.m_CurrentStep <> "1" Then\r
691       If g_fs.FileExists( status.m_NewPatchPath ) Then\r
692         echo "Starting Diff tool : " + Opt.m_DiffPath\r
693         g_sh.Run """"+Opt.m_DiffPath+""" """+status.m_OldPatchPath+""" """+status.m_NewPatchPath+""" """+NewPath+""""\r
694       End If\r
695     End If\r
696    Case 5 : OpenMergePath  Opt.m_EditorPath, OldPath\r
697    Case 6 : OpenMergePath  Opt.m_EditorPath, NewPath\r
698 \r
699    Case 7\r
700     Select Case  status.m_CurrentStep\r
701      Case "1"\r
702       src_path = status.m_OldPatchPath : dst_path = "Editing\" + status.m_NewPatchStepPath\r
703       If g_fs.FolderExists( src_path ) Then  src_path = src_path + "\*"\r
704       echo  "copy """ + src_path + """, """ + dst_path + """"\r
705       copy  src_path, dst_path\r
706      Case "2"\r
707       src_path = status.m_NewPatchPath : dst_path = "New\" + status.m_NewPatchStepPath\r
708       If g_fs.FolderExists( src_path ) Then  src_path = src_path + "\*"\r
709       echo  "copy """ + src_path + """, """ + dst_path + """"\r
710       copy  src_path, dst_path\r
711     End Select\r
712 \r
713    Case 8\r
714     If not IsEmpty( status.m_NewPatchPath ) Then\r
715       i = input( "\91O\83X\83e\83b\83v\82É\96ß\82é\82½\82ß\81A" + status.m_NewPatchPath + " \82ð\8dí\8f\9c\82µ\82Ü\82·\81B[Y/N]" )\r
716       If i = "y" or i = "Y" Then  del status.m_NewPatchPath\r
717     End If\r
718    Case 9 : Exit Sub\r
719   End Select\r
720  Loop\r
721 End Sub\r
722 \r
723 \r
724  \r
725 '********************************************************************************\r
726 '  <<< [GetMergeRepStep] >>> \r
727 '[argument]\r
728 '- Status as MergeRep_Status\r
729 '- (In)  Status.m_PatchFolderPath, Status.m_NewPatchStepPath\r
730 '- (Out) Status.m_CurrentStep and Status.m_NewPatchPath\r
731 '********************************************************************************\r
732 Sub  GetMergeRepStep( Status )\r
733   Dim  path\r
734 \r
735   path = "New\" + Status.m_NewPatchStepPath\r
736   If exist( path ) Then\r
737     Status.m_NewPatchPath = path : Status.m_CurrentStep = "Fin" : Exit Sub\r
738   End If\r
739 \r
740   path = "Editing\" + Status.m_NewPatchStepPath\r
741   If exist( path ) Then\r
742     Status.m_NewPatchPath = path : Status.m_CurrentStep = CStr( 2 ) : Exit Sub\r
743   End If\r
744 \r
745   Status.m_NewPatchPath = Empty : Status.m_CurrentStep = CStr( 1 )\r
746 End Sub\r
747 \r
748 \r
749 \r
750 \r
751  \r
752 '*-------------------------------------------------------------------------*\r
753 '* \81\9f<<<< [MergeRep_Status] Class >>>> */ \r
754 '*-------------------------------------------------------------------------*\r
755 \r
756 \r
757 Class  MergeRep_Status\r
758   Public  m_PatchFolderPath\r
759   Public  m_OldPatchStepPath\r
760   Public  m_NewPatchStepPath\r
761 \r
762   Public  m_OldPatchPath\r
763   Public  m_NewPatchPath\r
764 \r
765   Public  m_CurrentStep\r
766 End Class\r
767 \r
768 \r
769 \r
770  \r
771 '*-------------------------------------------------------------------------*\r
772 '* \81\9f<<<< [PatchFiles] Class >>>> */ \r
773 '*-------------------------------------------------------------------------*\r
774 \r
775 Class  PatchFiles\r
776   Public  m_MergeOption     ' as Merge_Option\r
777   Public  m_OldFolderPath   ' as string\r
778   Public  m_OldFolderPath2  ' as string\r
779   Public  m_PatchFolderPath ' as string\r
780   Public  m_NewFolderPath   ' as string\r
781   Public  m_Items()        ' as array of PatchFile\r
782   Public  m_RenamedFrom()  ' as array of string. step path\r
783   Public  m_RenamedTo()    ' as array of string. step path\r
784   Public  m_IDefault\r
785 \r
786   Public  m_PatchFileType  '//Const\r
787   Public  m_ReplaceType    '//Const\r
788 \r
789   Private Sub Class_Initialize\r
790     Me.m_PatchFileType = 1\r
791     Me.m_ReplaceType = 2\r
792     ReDim  m_Items(-1)\r
793     ReDim  m_RenamedFrom(-1)\r
794     ReDim  m_RenamedTo(-1)\r
795     g_sh.CurrentDirectory = g_fs.GetParentFolderName( WScript.ScriptFullName )\r
796   End Sub\r
797 \r
798   Public Sub  AddPatchFile( StepPath )\r
799     Dim item : Set item = new PatchFile : ErrCheck\r
800 \r
801     With  item\r
802       Set .m_Parent = Me\r
803       .m_Type = Me.m_PatchFileType\r
804       .m_StepPath = StepPath\r
805     End With\r
806 \r
807     ReDim Preserve  m_Items( UBound( m_Items ) + 1 )\r
808     Set  m_Items( UBound( m_Items ) ) = item\r
809   End Sub\r
810 \r
811   Public Sub  AddReplace( OldStepPath, NewStepPath, PatchStepPath )\r
812     Dim item : Set item = New ReplaceFile\r
813 \r
814     With  item\r
815       Set .m_Parent = Me\r
816       .m_Type = Me.m_ReplaceType\r
817       .m_OldStepPath = OldStepPath\r
818       .m_NewStepPath = NewStepPath\r
819       .m_StepPath = PatchStepPath\r
820     End With\r
821 \r
822     ReDim Preserve  m_Items( UBound( m_Items ) + 1 )\r
823     Set  m_Items( UBound( m_Items ) ) = item\r
824   End Sub\r
825 \r
826   Public Sub  AddRenamed( OldStepPath, NewStepPath )\r
827     ReDim Preserve  m_RenamedFrom( UBound( m_RenamedFrom ) + 1 )\r
828     m_RenamedFrom( UBound( m_RenamedFrom ) ) = OldStepPath\r
829 \r
830     ReDim Preserve  m_RenamedTo( UBound( m_RenamedTo ) + 1 )\r
831     m_RenamedTo( UBound( m_RenamedTo ) ) = NewStepPath\r
832   End Sub\r
833 \r
834   Public Function  GetRenamedPath( ByVal path )\r
835     Dim  i\r
836 \r
837     For i = 0 To  UBound( Me.m_RenamedFrom )\r
838       If Me.m_RenamedFrom(i) = Left( path, Len(Me.m_RenamedFrom(i)) ) Then\r
839         path = Me.m_RenamedTo(i) + Mid( path, Len(Me.m_RenamedFrom(i)) + 1 )\r
840         Exit For\r
841       End If\r
842     Next\r
843     GetRenamedPath = path\r
844   End Function\r
845 \r
846   Public Sub  EchoSteps()\r
847     Dim  step_\r
848     echo  "[Update_Merge_Steps]"\r
849     Me.m_IDefault = Empty\r
850     For i=0 To UBound( Me.m_Items )\r
851       step_ = Me.m_Items(i).GetStep() : If step_<>"Fin" and IsEmpty(Me.m_IDefault) Then  Me.m_IDefault = i\r
852       echo  (i+1) & ") Step=" & step_ & " : " + Me.m_Items(i).m_StepPath\r
853     Next\r
854     If IsEmpty( Me.m_IDefault ) Then\r
855       echo  "All items are Finished."\r
856     Else\r
857       If UBound( Me.m_Items ) > 10 Then\r
858         i = Me.m_IDefault\r
859         step_ = Me.m_Items(i).GetStep()\r
860         echo  "0) Step=" & step_ & " : " + Me.m_Items(i).m_StepPath\r
861       End If\r
862     End If\r
863   End Sub\r
864 \r
865   Public Sub  RunMergePrompt()\r
866     g_CUI.SetAutoKeysFromMainArg\r
867     Do\r
868       Me.EchoSteps\r
869       echo "-1) exit"\r
870       i = CInt2( input( "\83}\81[\83W\82·\82é\83t\83@\83C\83\8b\82Ì\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢>" ) )\r
871       If i = -1 Then Exit Sub\r
872       echo "-------------------------------------------"\r
873       If i = 0 and ( not IsEmpty( Me.m_IDefault ) )  Then  i = Me.m_IDefault + 1\r
874       If i <= UBound( Me.m_Items )+1 Then  Me.m_Items(i-1).RunMergePromptMe\r
875     Loop\r
876   End Sub\r
877 End Class\r
878 \r
879 \r
880  \r
881 '*-------------------------------------------------------------------------*\r
882 '* \81\9f<<<< [PatchFile] Class >>>> */ \r
883 '*-------------------------------------------------------------------------*\r
884 \r
885 Class  PatchFile\r
886   Public  m_Parent ' as PatchFiles\r
887   Public  m_Type  '// PatchFiles::m_PatchFileType\r
888 \r
889   Public  m_StepPath\r
890 \r
891   Public Sub  RunMergePromptMe()\r
892     Dim  pathes()\r
893     Me_SetupParams  pathes\r
894     RunMergePrompt  pathes, m_Parent.m_MergeOption\r
895   End Sub\r
896 \r
897   Public  Function  GetStep()\r
898     Dim  pathes()\r
899     Me_SetupParams  pathes\r
900     GetStep = GetMergeStep( pathes, m_Parent.m_MergeOption )\r
901   End Function\r
902 \r
903   Private Sub  Me_SetupParams( pathes )\r
904     Dim    i, path\r
905     Redim  pathes(2)\r
906 \r
907     i = 0\r
908 \r
909     '//=== Old\r
910     path = Me.m_Parent.m_OldFolderPath   + "\" + Me.m_StepPath\r
911     If exist( path ) Then\r
912       pathes(i) = path : i=i+1\r
913     ElseIf not IsEmpty( Me.m_Parent.m_OldFolderPath2 ) Then\r
914       path = Me.m_Parent.m_OldFolderPath2+ "\" + Me.m_StepPath\r
915       If exist( path ) Then  pathes(i) = path : i=i+1\r
916     End If\r
917 \r
918     '//=== Patch\r
919     path = Me.m_Parent.m_PatchFolderPath + "\" + Me.m_StepPath\r
920     If exist( path ) Then  pathes(i) = path : i=i+1\r
921 \r
922 \r
923     '//=== New\r
924     path = Me.m_Parent.m_NewFolderPath   + "\" + Me.m_StepPath\r
925     path = Me.m_Parent.GetRenamedPath( path )\r
926     If exist( path ) Then  pathes(i) = path : i=i+1\r
927     Redim Preserve  pathes(i-1)\r
928 \r
929 \r
930     '//=== Fin\r
931     Me.m_Parent.m_MergeOption.m_NewPath = "New\" + Me.m_StepPath\r
932   End Sub\r
933 \r
934 End Class\r
935 \r
936 \r
937  \r
938 '*-------------------------------------------------------------------------*\r
939 '* \81\9f<<<< [ReplaceFile] Class >>>> */ \r
940 '*-------------------------------------------------------------------------*\r
941 \r
942 Class  ReplaceFile\r
943   Public  m_Parent ' as PatchFiles\r
944   Public  m_Type  '// PatchFiles::m_ReplaceType\r
945 \r
946   Public  m_StepPath  '// PatchPath\r
947   Public  m_OldStepPath\r
948   Public  m_NewStepPath\r
949 \r
950   Public Sub  RunMergePromptMe()\r
951     RunMergeRepPrompt _\r
952       Me.m_Parent.m_OldFolderPath + "\" + m_OldStepPath, _\r
953       Me.m_Parent.m_NewFolderPath + "\" + Me.m_Parent.GetRenamedPath( m_NewStepPath ), _\r
954       Me.m_Parent.m_PatchFolderPath, _\r
955       m_StepPath, _\r
956       Me.m_Parent.GetRenamedPath( m_StepPath ), _\r
957       Me.m_Parent.m_MergeOption\r
958   End Sub\r
959 \r
960   Public  Function  GetStep()\r
961     Dim status : Set status = new MergeRep_Status : ErrCheck\r
962     status.m_PatchFolderPath = Me.m_Parent.m_PatchFolderPath\r
963     status.m_NewPatchStepPath = Me.m_Parent.GetRenamedPath( m_StepPath )\r
964     GetMergeRepStep  status\r
965     GetStep = status.m_CurrentStep\r
966   End Function\r
967 \r
968 End Class\r
969 \r
970  \r
971 '*-------------------------------------------------------------------------*\r
972 '* \81\9f<<<< [SyncFiles] Class >>>> */ \r
973 '*-------------------------------------------------------------------------*\r
974 \r
975 Class  SyncFiles\r
976   Public  m_MergeOption  ' as Merge_Option\r
977   Public  m_Items()   ' as array of SyncFile\r
978   Public  m_SubCount  ' as integer\r
979   Public  m_IDefault\r
980 \r
981   Private Sub Class_Initialize\r
982     ReDim  m_Items(-1)\r
983     Me.m_SubCount = 0\r
984     g_sh.CurrentDirectory = g_fs.GetParentFolderName( WScript.ScriptFullName )\r
985   End Sub\r
986 \r
987   Public Sub  NextSyncFile()\r
988     Me.m_SubCount = 0\r
989   End Sub\r
990 \r
991   Public Sub  AddRepliFile( Path )\r
992     Dim item : Set item = AddFileSub( Path )\r
993     item.AddFile  Path\r
994   End Sub\r
995 \r
996   Public Sub  AddSameFile( Path )\r
997     Dim item : Set item = AddFileSub( Path )\r
998     item.AddSameFile  Path\r
999   End Sub\r
1000 \r
1001   Private Function  AddFileSub( Path )\r
1002     Dim  item\r
1003 \r
1004     If Me.m_SubCount = 0 Then\r
1005       Set item = new SyncFile : ErrCheck\r
1006       ReDim Preserve  m_Items( UBound( m_Items ) + 1 )\r
1007       Set  m_Items( UBound( m_Items ) ) = item\r
1008 \r
1009       Set item.m_Parent = Me\r
1010       item.m_Name = g_fs.GetFileName( Path )\r
1011     Else\r
1012       Set item = m_Items( UBound( m_Items ) )\r
1013     End If\r
1014     Me.m_SubCount = Me.m_SubCount + 1\r
1015 \r
1016     Set AddFileSub = item\r
1017   End Function\r
1018 \r
1019   Public Sub  EchoSteps()\r
1020     Dim  step_\r
1021     echo  "[Sync_Merge_Steps]"\r
1022     Me.m_IDefault = Empty\r
1023     For i=0 To UBound( Me.m_Items )\r
1024       step_ = Me.m_Items(i).GetStep() : If step_<>"Fin" and IsEmpty(Me.m_IDefault) Then  Me.m_IDefault = i\r
1025       echo  (i+1) & ") Step=" & step_ + " : " + Me.m_Items(i).m_Name\r
1026     Next\r
1027     If IsEmpty( Me.m_IDefault ) Then\r
1028       echo  "All items are Finished."\r
1029     Else\r
1030       If UBound( Me.m_Items ) > 10 Then\r
1031         i = Me.m_IDefault\r
1032         step_ = Me.m_Items(i).GetStep()\r
1033         echo  "0) Step=" & step_ + " : " + Me.m_Items(i).m_Name\r
1034       End If\r
1035     End If\r
1036   End Sub\r
1037 \r
1038   Public Sub  RunMergePrompt()\r
1039     g_CUI.SetAutoKeysFromMainArg\r
1040     Do\r
1041       echo "-------------------------------------------"\r
1042       Me.EchoSteps\r
1043       echo "-1) exit"\r
1044       i = CInt2( input( "\83}\81[\83W\82·\82é\83t\83@\83C\83\8b\82Ì\94Ô\8d\86\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢>" ) )\r
1045       If i = -1 Then Exit Sub\r
1046       If i = 0 and ( not IsEmpty( Me.m_IDefault ) )  Then  i = Me.m_IDefault + 1\r
1047       If i <= UBound( Me.m_Items )+1 Then  Me.m_Items(i-1).RunMergePromptMe\r
1048     Loop\r
1049   End Sub\r
1050 End Class\r
1051 \r
1052 \r
1053 \r
1054  \r
1055 '*-------------------------------------------------------------------------*\r
1056 '* \81\9f<<<< [SyncFile] Class >>>> */ \r
1057 '*-------------------------------------------------------------------------*\r
1058 \r
1059 Class  SyncFile\r
1060   Public  m_Parent  ' as SyncFiles\r
1061   Public  m_Name    ' as string\r
1062   Public  m_FilePathes()  ' as array of string\r
1063   Public  m_SameFilePathes()  ' as array of string\r
1064 \r
1065   Private Sub Class_Initialize\r
1066     ReDim  m_FilePathes(-1)\r
1067     ReDim  m_SameFilePathes(-1)\r
1068   End Sub\r
1069 \r
1070   Public Sub  AddFile( Path )\r
1071     ReDim Preserve  m_FilePathes( UBound( m_FilePathes ) + 1 )\r
1072     m_FilePathes( UBound( m_FilePathes ) ) = Path\r
1073   End Sub\r
1074 \r
1075   Public Sub  AddSameFile( Path )\r
1076     ReDim Preserve  m_SameFilePathes( UBound( m_SameFilePathes ) + 1 )\r
1077     m_SameFilePathes( UBound( m_SameFilePathes ) ) = Path\r
1078   End Sub\r
1079 \r
1080   Public Sub  RunMergePromptMe()\r
1081     Me.m_Parent.m_MergeOption.m_NewPath = Empty\r
1082     Me.m_Parent.m_MergeOption.m_SyncPathes = m_SameFilePathes\r
1083     RunMergePrompt  m_FilePathes, Me.m_Parent.m_MergeOption\r
1084   End Sub\r
1085 \r
1086   Public  Function  GetStep()\r
1087     Me.m_Parent.m_MergeOption.m_NewPath = Empty\r
1088     GetStep = GetMergeStep( Me.m_FilePathes, Me.m_Parent.m_MergeOption )\r
1089   End Function\r
1090 End Class\r
1091 \r
1092 \r
1093  \r