-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathxnuremake.prw
88 lines (82 loc) · 2.52 KB
/
xnuremake.prw
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
#INCLUDE "TOTVS.CH"
#INCLUDE "FILEIO.CH"
** Criado por: Alessandro de Farias - [email protected] - Em: 10/04/2021
User Function xnuremake
Local nI, nJ
Local cOrigem := "d:\r27\protheus_data\temp\"
Local aPastas := {"menu_pasta1","menu_pasta2","menu_pasta2"}
Local aDir := {}
Local dDestino:= "D:\R27\protheus_data\temp\novos_menus"
For nI:=1 To Len(aPastas)
aDir := Directory( cOrigem+aPastas[nI]+"\*.xnu" )
For nJ:=1 To Len(aDir)
If ! 'copy' $ lower(aDir[nJ][01])
ConOut( cOrigem+aPastas[nI]+"\"+aDir[nJ][01] + " -> " + lower(dDestino+"\"+aPastas[nI]+aDir[nJ][01]) )
remake( cOrigem+aPastas[nI]+"\"+aDir[nJ][01], lower(dDestino+"\"+aPastas[nI]+aDir[nJ][01]) )
Endif
Next nJ
Next nI
Return
Static Function remake( cMenu, cNewNemnu )
Local cLine := Access := ''
Local aLinhas := {}
Local nI := 1
FT_FUSE( cMenu )
FT_FGOTOP()
Do While ! FT_FEOF()
cLine := FT_FREADLN()
If Lower('<Access>') $ Lower( cLine ) .And. Lower('</Access>') $ Lower( cLine )
Access := Substr( cLine, At('>',cLine)+1 )
Access := Substr( Access, 1, At('<',Access)-1)
Access := padr(lower(Left(Access,10)),10)
cLine := ' '+'<Access>'+Access+'</Access>'
Endif
If Lower('<Module>') $ Lower( cLine ) .And. Lower('</Module>') $ Lower( cLine )
Module := Substr( cLine, At('>',cLine)+1 )
Module := Substr( Module, 1, At('<',Module)-1)
If Empty(Module) .Or. Module == "0"
Module := '06'
Endif
cLine := ' '+'<Module>'+Module+'</Module>'
Endif
If Lower('<Version>') $ Lower( cLine ) .And. Lower('</Version>') $ Lower( cLine )
Version := Substr( cLine, At('>',cLine)+1 )
Version := Substr( Version, 1, At('<',Version)-1)
If Empty(Version)
Version := '10.1'
Endif
cLine := ' '+'<Version>'+Version+'</Version>'
Endif
If Lower('<Type>') $ Lower( cLine ) .And. Lower('</Type>') $ Lower( cLine )
cType := Substr( cLine, At('>',cLine)+1 )
cType := Substr( cType, 1, At('<',cType)-1)
If Empty(cType) .Or. cType == "0"
cType := '03'
Endif
cLine := ' '+'<Type>'+cType+'</Type>'
Endif
If !Empty(Alltrim(cLine))
aAdd(aLinhas,cLine)
Endif
FT_FSKIP()
Enddo
FT_FUSE()
For nI:=1 To Len(aLinhas)
If nI == 1
fErase(cNewNemnu)
Endif
grv2txt( cNewNemnu, aLinhas[nI] )
Next nI
Return
Static Function grv2txt( cArquivo, cTexto )
Local nHdl := 0
If !File(cArquivo)
nHdl := FCreate(cArquivo)
Else
nHdl := FOpen(cArquivo, FO_READWRITE)
Endif
FSeek(nHdl,0,FS_END)
cTexto += Chr(13)+Chr(10)
FWrite(nHdl, cTexto, Len(cTexto))
FClose(nHdl)
Return