-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.frm
620 lines (565 loc) · 19.8 KB
/
Form1.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmMain
BackColor = &H80000004&
BorderStyle = 1 'Fixed Single
Caption = "Dir2HTML"
ClientHeight = 7755
ClientLeft = 4845
ClientTop = 2625
ClientWidth = 6675
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7755
ScaleWidth = 6675
Begin VB.Frame Frame3
Caption = "XML Export"
Height = 1335
Left = 60
TabIndex = 23
Top = 6090
Width = 6525
Begin VB.CheckBox Check3
Caption = "Use HTTP address (virtual directory):"
Height = 255
Left = 35
TabIndex = 30
Top = 270
Width = 2955
End
Begin VB.TextBox Text5
Height = 285
Left = 3060
TabIndex = 29
Text = "http://"
ToolTipText = "The name of the virtual directory"
Top = 240
Width = 3345
End
Begin VB.TextBox txtXSL
Height = 285
Left = 1500
TabIndex = 28
Text = "c:\temp\TreeDesign.xsl"
ToolTipText = "path to the XSL file which converts the XML to a readable structure"
Top = 600
Width = 4900
End
Begin VB.TextBox txtXMLFileName
Height = 285
Left = 930
TabIndex = 25
Text = "c:\temp\Dir2HTML.xml"
ToolTipText = "Name of the file to which the export is written"
Top = 930
Width = 4335
End
Begin VB.CommandButton cmdXMLExport
Caption = "Export"
Height = 285
Left = 5340
TabIndex = 24
Top = 930
Width = 1095
End
Begin VB.Label Label5
Caption = "Path to XSL: "
Height = 315
Left = 60
TabIndex = 27
Top = 570
Width = 1485
End
Begin VB.Label Label2
Caption = "File name:"
Height = 195
Left = 90
TabIndex = 26
Top = 960
Width = 825
End
End
Begin VB.Frame Frame2
Caption = "HTML Export"
Height = 2115
Left = 30
TabIndex = 13
Top = 3900
Width = 6585
Begin VB.TextBox txtTarget
Height = 285
Left = 3150
TabIndex = 22
Text = "_self"
ToolTipText = "Name of the target frame"
Top = 960
Width = 3345
End
Begin VB.CheckBox chkTarget
Caption = "Use target:"
Height = 255
Left = 90
TabIndex = 21
Top = 1020
Width = 2955
End
Begin VB.TextBox txtImages
Height = 285
Left = 3150
TabIndex = 20
Text = "c:\temp\images\"
ToolTipText = "The path to the images, can be absolute or relative"
Top = 600
Width = 3345
End
Begin VB.CheckBox chkImages
Caption = "Path to images:"
Height = 255
Left = 90
TabIndex = 19
Top = 660
Width = 2955
End
Begin VB.CommandButton cmdExport
Caption = "Export"
Height = 285
Left = 5370
TabIndex = 17
ToolTipText = "Start the export process"
Top = 1530
Width = 1095
End
Begin VB.TextBox Text4
Height = 285
Left = 3150
TabIndex = 16
Text = "http://"
ToolTipText = "The name of the virtual directory"
Top = 240
Width = 3345
End
Begin VB.CheckBox Check2
Caption = "Use HTTP address (virtual directory):"
Height = 255
Left = 90
TabIndex = 15
Top = 330
Width = 2955
End
Begin VB.TextBox txtFileName
Height = 285
Left = 960
TabIndex = 14
Text = "c:\temp\Dir2HTML.htm"
ToolTipText = "Name of the file to which the export is written"
Top = 1530
Width = 4335
End
Begin VB.Label Label1
Caption = "File name:"
Height = 195
Left = 90
TabIndex = 18
Top = 1560
Width = 825
End
End
Begin VB.Frame Frame1
Caption = "Folders"
Height = 795
Left = 0
TabIndex = 8
Top = 3030
Width = 6615
Begin VB.CommandButton cmdPlus
DownPicture = "Form1.frx":030A
Height = 360
Left = 150
Picture = "Form1.frx":0494
Style = 1 'Graphical
TabIndex = 12
ToolTipText = "Add a folder"
Top = 300
Width = 420
End
Begin VB.CommandButton cmdMin
DownPicture = "Form1.frx":0AE6
Height = 360
Left = 630
Picture = "Form1.frx":0C70
Style = 1 'Graphical
TabIndex = 11
ToolTipText = "Remove a folder"
Top = 300
Width = 375
End
Begin VB.TextBox Text1
BackColor = &H00C0C0C0&
Height = 285
Left = 1110
TabIndex = 10
Text = "New Folder"
ToolTipText = "Name of the new folder"
Top = 360
Width = 3195
End
Begin VB.CheckBox Check1
Caption = "Check for no confirmation"
Height = 240
Left = 4380
TabIndex = 9
ToolTipText = "Check if you do not want to confirm each time"
Top = 375
Width = 2160
End
End
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 255
Left = 0
TabIndex = 7
Top = 7500
Width = 6675
_ExtentX = 11774
_ExtentY = 450
Style = 1
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton Command6
Caption = "Get folder to delete name"
Height = 315
Left = 7050
TabIndex = 6
Top = 2400
Width = 1980
End
Begin VB.TextBox Text3
Height = 330
Left = 6990
TabIndex = 5
Text = "Text3"
Top = 2070
Width = 3360
End
Begin VB.CommandButton Command5
Caption = "New folder path?"
Height = 270
Left = 7005
TabIndex = 4
Top = 1350
Width = 1785
End
Begin VB.TextBox Text2
Height = 300
Left = 7005
TabIndex = 3
Text = "Text2"
Top = 1635
Width = 3405
End
Begin VB.FileListBox File1
BackColor = &H00C0C0C0&
Height = 3015
Left = 3240
TabIndex = 2
ToolTipText = "Filelist"
Top = 30
Width = 3420
End
Begin VB.DirListBox Dir1
BackColor = &H00C0C0C0&
Height = 2565
Left = 15
TabIndex = 1
ToolTipText = "Directories"
Top = 435
Width = 3150
End
Begin VB.DriveListBox Drive1
BackColor = &H00C0C0C0&
Height = 315
Left = 60
TabIndex = 0
ToolTipText = "Drives"
Top = 60
Width = 3135
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'===============================================
'Dir2XML
'comments are welcome
'frodooo@hotmail.com
'===============================================
Dim Extra As String
Dim RemoveChars As Integer
Dim ImPath As String
Public uniqueID As Integer
Private Enum ExportType
HTMLType
XMLType
End Enum
Const sDTD = "<!DOCTYPE folders[ " & vbCrLf & _
"<!ELEMENT folders (folder|file)+>" & vbCrLf & _
"<!ELEMENT folder (file| folder)*>" & vbCrLf & _
"<!ELEMENT file (TITLE, URL)>" & vbCrLf & _
"<!ELEMENT TITLE (#PCDATA)>" & vbCrLf & _
"<!ELEMENT URL (#PCDATA)>" & vbCrLf & _
"<!ATTLIST folders" & vbCrLf & _
"DIRNAME CDATA #REQUIRED" & vbCrLf & _
"ID ID #REQUIRED" & vbCrLf & _
">" & vbCrLf & _
"<!ATTLIST folder" & vbCrLf & _
"DIRNAME CDATA #REQUIRED" & vbCrLf & _
"ID ID #REQUIRED" & vbCrLf & _
">" & vbCrLf & _
"<!ATTLIST file" & vbCrLf & _
"FILENAME CDATA #REQUIRED" & vbCrLf & _
"ID ID #REQUIRED" & vbCrLf & _
">" & vbCrLf & _
"<!ATTLIST TITLE" & vbCrLf & _
"ID ID #REQUIRED" & vbCrLf & _
">" & vbCrLf & _
"<!ATTLIST URL" & vbCrLf & _
"ID ID #REQUIRED" & vbCrLf & _
">" & vbCrLf & _
"]>"
Private Sub cmdPlus_Click()
On Error GoTo errorfolder:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
MyFoldersPath$ = File1.Path
If Not Right(MyFoldersPath$, 1) = "\" Then
MyFoldersPPath$ = MyFoldersPath$ & "\" & Text1.Text
fso.CreateFolder File1.Path & "\" & Text1.Text
Else
fso.CreateFolder File1.Path & Text1.Text
End If
Dir1.Refresh
errorfolder:
If Err = 58 Then MsgBox "File already exists"
Exit Sub
End Sub
Private Sub cmdMin_Click()
If Check1.Value = 1 Then
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder File1.Path, force = True
Dir1.Path = Left$(Dir1.Path, InStrRev(Dir1.Path, "\"))
Dir1.Refresh
File1.Refresh
Exit Sub
Else
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Are you sure you want to delete " & Dir1.Path & " ?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "DELETE A FOLDER"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
MyString = "Yes"
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder File1.Path, force = True
Dir1.Path = Left$(Dir1.Path, InStrRev(Dir1.Path, "\"))
Dir1.Refresh
File1.Refresh
Else
MyString = "No"
MsgBox "Folder and it's contents remain intact", vbInformation, "Dir2HTML"
Exit Sub
End If
End If
Exit Sub
End Sub
Private Sub cmdExport_Click()
Dim fso
If chkImages.Value = 1 Then
ImPath = txtImages.Text
If Not (Right(ImPath, 1) = "/") Then
ImPath = ImPath & "/"
End If
Else
ImPath = ""
End If
If chkTarget.Value = 1 Then
sTarget = txtTarget.Text
Else
sTarget = ""
End If
Response = MsgBox("Export the selected directory?", vbYesNo, "Dir2HTML")
Dim k As Integer
If Response = vbYes Then
Screen.MousePointer = vbHourglass
If Check2.Value = 1 Then
Extra = Text4.Text
If Right(Extra, 1) = "/" Then
Extra = Left(Extra, Len(Extra) - 1)
End If
TopName = Text4.Text
RemoveChars = Len(Dir1.List(Dir1.ListIndex))
Else
Extra = ""
TopName = Dir1.List(Dir1.ListIndex)
RemoveChars = 0
End If
sFileName = txtFileName.Text
Open sFileName For Output As #1
Print #1, "<html>" & vbCrLf & "<head><title>Inventory of " & Drive1.Name & "</title></head><body><font face=""verdana"" size=""1"">"
Print #1, "<b>" & TopName & "</b><br>" & vbCrLf
For k = 0 To Dir1.ListCount - 1
Print #1, "<img src=""" & ImPath & "node.gif"" valign=""baseline""><img src=""" & ImPath & "FClosed.gif"" valign=""middle""> <a href=""" & Extra & Right(Dir1.List(k), Len(Dir1.List(k)) - RemoveChars) & """ target=""" & sTarget & """>" & Right(Dir1.List(k), Len(Dir1.List(k)) - InStrRev(Dir1.List(k), "\")) & "</a><br>" & vbCrLf
If Not DirPath = "" Or DirParent = "" Then
GoThroughDir HTMLType, 1, Dir1.List(k), Dir1.Path, 1
End If
Next
For i = 0 To File1.ListCount - 1
Print #1, ExtraSpace & "<img src=""" & ImPath & "node.gif"" height=""22"" align=""absmiddle""><a href=""" & Extra & Right(File1.Path, Len(File1.Path) - RemoveChars) & "\" & File1.List(i) & """ target=""" & sTarget & """>" & File1.List(i) & "</a><br>" & vbCrLf
Next
Print #1, "</font></body></html>"
Close #1
Screen.MousePointer = vbDefault
MsgBox "HTML file written.", vbInformation, "Dir2HTML"
End If
End Sub
Private Sub cmdXMLExport_Click()
Response = MsgBox("Export the selected directory?", vbYesNo, "Dir2HTML")
Dim k As Integer
uniqueID = 1
If Response = vbYes Then
Screen.MousePointer = vbHourglass
If Check3.Value = 1 Then
Extra = Text5.Text
If Right(Extra, 1) = "/" Then
Extra = Left(Extra, Len(Extra) - 1)
End If
TopName = Text5.Text
RemoveChars = Len(Dir1.List(Dir1.ListIndex))
Else
Extra = ""
TopName = Dir1.List(Dir1.ListIndex)
RemoveChars = 0
End If
sFileName = txtXMLFileName.Text
Open sFileName For Output As #1
Print #1, "<?xml version=""1.0""?>" & vbCrLf & sDTD & vbCrLf
Print #1, "<?xml-stylesheet type=""text/xsl"" href=""" & txtXSL.Text & """?>" & vbCrLf
Print #1, "<folders ID=""ID" & uniqueID & """ DIRNAME=""" & Dir1.List(Dir1.ListIndex) & """>" & vbCrLf
For k = 0 To Dir1.ListCount - 1
Print #1, "<folder ID=""ID" & increment(uniqueID) & """ DIRNAME=""" & Right(Dir1.List(k), Len(Dir1.List(k)) - InStrRev(Dir1.List(k), "\")) & """>" & vbCrLf
If Not DirPath = "" Or DirParent = "" Then
GoThroughDir XMLType, 1, Dir1.List(k), Dir1.Path, 1
End If
Print #1, "</folder>" & vbCrLf
Next
For i = 0 To File1.ListCount - 1
Print #1, ExtraSpace & "<file ID=""ID" & increment(uniqueID) & """ FILENAME=""" & File1.List(i) & """>" & vbCrLf & _
"<TITLE ID=""ID" & increment(uniqueID) & """>" & File1.List(i) & "</TITLE>" & vbCrLf & _
"<URL ID=""ID" & increment(uniqueID) & """>" & Extra & Right(File1.Path, Len(File1.Path) - RemoveChars) & "/" & File1.List(i) & "</URL>" & vbCrLf & _
"</file>" & vbCrLf
Next
Print #1, "</folders>"
Close #1
Screen.MousePointer = vbDefault
MsgBox "XML file written.", vbInformation, "Dir2HTML"
End If
End Sub
Private Sub GoThroughDir(FileType As ExportType, FileNum As Integer, DirPath As String, DirParent As String, ByVal spaceCount As Integer)
Dim i As Integer
Dim ExtraSpace As String
Select Case FileType
Case XMLType
StartFolder1 = "<folder DIRNAME="""
StartFolder2 = """>"
StartID = """ ID=""ID"
EndFolder = "</folder>"
StartFileBegin = "<file FILENAME="""
StartFileEnd = """>"
EndFile = "</file>"
ExtraSpace = ""
If Not DirPath = "" Or DirParent = "" Then
Dir1.Path = DirPath
Print #FileNum, ""
For i = 0 To Dir1.ListCount - 1
Print #FileNum, ExtraSpace & _
StartFolder1 & Right(Dir1.List(i), Len(Dir1.List(i)) - InStrRev(Dir1.List(i), "\")) & _
StartID & increment(uniqueID) & _
StartFolder2 & vbCrLf
GoThroughDir FileType, FileNum, Dir1.List(i), DirPath, spaceCount + 1
Print #FileNum, EndFolder
Next
For i = 0 To File1.ListCount - 1
Print #FileNum, ExtraSpace & StartFileBegin & File1.List(i) & StartID & increment(uniqueID) & _
StartFileEnd & vbCrLf & _
"<TITLE ID=""ID" & increment(uniqueID) & """>" & File1.List(i) & "</TITLE>" & vbCrLf & _
"<URL ID=""ID" & increment(uniqueID) & """>" & Extra & Right(File1.Path, Len(File1.Path) - RemoveChars) & "/" & File1.List(i) & "</URL>" & vbCrLf & _
EndFile & vbCrLf
Next
Dir1.Path = DirParent
End If
Case HTMLType
ExtraSpace = PrintSpace(spaceCount + 1)
StartFolder = "<img src=""" & ImPath & "FClosed.gif"" valign=""baseline"">" & _
"<a href=""" & Extra & Right(Dir1.List(i), Len(Dir1.List(i)) - RemoveChars) & """ target=""" & sTarget & """>"
EndFolder = "</a><br>"
Startfile = "<img src=""" & ImPath & "node.gif"" height=""22"" valign=""baseline"">" & _
"<a href=""" & Extra & Right(File1.Path, Len(File1.Path) - RemoveChars) & "\" & File1.List(i) & """ target=""" & sTarget & """>"
EndFile = "</a><br>"
If Not DirPath = "" Or DirParent = "" Then
Dir1.Path = DirPath
Print #FileNum, ""
For i = 0 To Dir1.ListCount - 1
Print #FileNum, ExtraSpace & StartFolder & Right(Dir1.List(i), Len(Dir1.List(i)) - InStrRev(Dir1.List(i), "\")) & EndFolder & vbCrLf
GoThroughDir FileType, FileNum, Dir1.List(i), DirPath, spaceCount + 1
Next
For i = 0 To File1.ListCount - 1
Print #FileNum, ExtraSpace & Startfile & File1.List(i) & EndFile & vbCrLf
Next
Dir1.Path = DirParent
End If
End Select
End Sub
Private Function PrintSpace(amount As Integer) As String
Dim temp As String
For k = 1 To amount
temp = temp & "<img src=""" & ImPath & "vertline.gif"" height=""22"" width=""16"">"
Next
PrintSpace = temp
End Function
Private Sub Dir1_Change()
File1.Path = Dir1.Path
StatusBar1.SimpleText = Dir1.Path & " Containing " & File1.ListCount & " Files"
End Sub
Private Sub Dir1_Click()
With Dir1
.Path = .List(.ListIndex)
End With
End Sub
Private Sub Drive1_Change()
On Error GoTo errDrive
Dir1.Path = Drive1.Drive
errDrive:
If Err.Number = 68 Then
MsgBox "Drive Not Ready!", vbOKOnly, "Dir2HTML"
Exit Sub
Else
Exit Sub
End If
End Sub
Private Sub Form_Load()
Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path
End Sub
Private Function increment(ByRef counter As Integer) As Integer
counter = counter + 1
increment = counter
End Function