MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / ReadZip

Function ReadZip

contrib/diff-scripts/diff-zip.js:62–105  ·  view source on GitHub ↗
(pathToZipFile)

Source from the content-addressed store, hash-verified

60// Read a zip file contents and write to a temporary file.
61// Return the file name, or empty if an error occured.
62function ReadZip(pathToZipFile)
63{
64 var Folder;
65 Folder = ShellApplication.NameSpace(pathToZipFile);
66 if (!Folder)
67 {
68 MsgBox("Cannot read " + pathToZipFile, 48, "diff-zip.js");
69 return "";
70 }
71 else
72 {
73 var Items, File;
74 Items = Folder.Items();
75 FileName = FileSystemObject.GetSpecialFolder(2) + "\\" + FileSystemObject.GetTempName();
76 // 2 = ForWriting
77 // -1 = Opens the file as Unicode
78 File = FileSystemObject.OpenTextFile(FileName, 2, true, -1);
79 if (!File)
80 {
81 MsgBox("Cannot open " + File + " for writing", 48, "diff-zip.js");
82 return "";
83 }
84
85 File.WriteLine(pathToZipFile);
86 File.WriteLine("");
87 var MaxLength = 20;
88 for (var i = 0; i < Items.Count; i++)
89 {
90 if (Items.Item(i).Name.length > MaxLength)
91 {
92 MaxLength = Items.Item(i).Name.length;
93 }
94 }
95 for (var i = 0; i < Items.Count; i++)
96 {
97 var Item = Items.Item(i);
98 File.WriteLine(Item.Name + new Array(MaxLength-Item.Name.length+2).join(" ") + Item.ModifyDate + new Array(11-Item.Size.toString().length).join(" ") + Item.Size);
99 }
100 File.WriteLine("");
101 File.WriteLine(Items.Count + " items");
102 File.Close();
103 return FileName;
104 }
105}
106
107// Read the two input zip files
108BaseFile = ReadZip(BaseFile)

Callers 1

diff-zip.jsFile · 0.85

Calls 4

GetSpecialFolderMethod · 0.80
toStringMethod · 0.80
MsgBoxFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected