|
114 | 114 | End If |
115 | 115 | End Sub |
116 | 116 |
|
117 | | - Public MustOverride Function AddDirectory(DirectoryData() As Byte, Options As AddFileOptions, LFNFileName As String, Optional Index As Integer = -1) As AddDirectoryData Implements IDirectory.AddDirectory |
| 117 | + Public MustOverride Function AddDirectory(EntryData() As Byte, Options As AddFileOptions, Filename As String, Optional Index As Integer = -1) As AddFileData Implements IDirectory.AddDirectory |
118 | 118 |
|
119 | 119 | Public MustOverride Function AddFile(FilePath As String, Options As AddFileOptions, Optional Index As Integer = -1) As Integer Implements IDirectory.AddFile |
120 | 120 |
|
|
137 | 137 | Return Index |
138 | 138 | End Function |
139 | 139 |
|
| 140 | + Public Function FindFileName(Filename As String, IncludeDirectories As Boolean, Optional SkipIndex As Integer = -1) As Integer Implements IDirectory.FindFileName |
| 141 | + If _DirectoryData.EntryCount > 0 Then |
| 142 | + For Counter As UInteger = 0 To _DirectoryData.EntryCount - 1 |
| 143 | + If Counter <> SkipIndex Then |
| 144 | + Dim File = _DirectoryEntries.Item(Counter) |
| 145 | + If Not File.IsDeleted And Not File.IsVolumeName And (IncludeDirectories Or Not File.IsDirectory) Then |
| 146 | + If File.GetFullFileName = Filename Then |
| 147 | + Return Counter |
| 148 | + End If |
| 149 | + End If |
| 150 | + End If |
| 151 | + Next |
| 152 | + End If |
| 153 | + |
| 154 | + Return -1 |
| 155 | + End Function |
| 156 | + |
| 157 | + Public Function FindShortFileName(FileBytes() As Byte, IncludeDirectories As Boolean, Optional SkipIndex As Integer = -1) As Integer Implements IDirectory.FindShortFileName |
| 158 | + If _DirectoryData.EntryCount > 0 Then |
| 159 | + For Counter As UInteger = 0 To _DirectoryData.EntryCount - 1 |
| 160 | + If Counter <> SkipIndex Then |
| 161 | + Dim File = _DirectoryEntries.Item(Counter) |
| 162 | + If Not File.IsDeleted And Not File.IsVolumeName And (IncludeDirectories Or Not File.IsDirectory) Then |
| 163 | + If FileBytes.CompareTo(File.FileNameWithExtension) Then |
| 164 | + Return Counter |
| 165 | + End If |
| 166 | + End If |
| 167 | + End If |
| 168 | + Next |
| 169 | + End If |
| 170 | + |
| 171 | + Return -1 |
| 172 | + End Function |
| 173 | + |
| 174 | + Public Function FindShortFileName(Filename As String, IncludeDirectories As Boolean, Optional SkipIndex As Integer = -1) As Integer Implements IDirectory.FindShortFileName |
| 175 | + If _DirectoryData.EntryCount > 0 Then |
| 176 | + For Counter As UInteger = 0 To _DirectoryData.EntryCount - 1 |
| 177 | + If Counter <> SkipIndex Then |
| 178 | + Dim File = _DirectoryEntries.Item(Counter) |
| 179 | + If Not File.IsDeleted And Not File.IsVolumeName And (IncludeDirectories Or Not File.IsDirectory) Then |
| 180 | + If File.GetShortFileName = Filename Then |
| 181 | + Return Counter |
| 182 | + End If |
| 183 | + End If |
| 184 | + End If |
| 185 | + Next |
| 186 | + End If |
| 187 | + |
| 188 | + Return -1 |
| 189 | + End Function |
| 190 | + |
140 | 191 | Public Function GetAvailableEntry() As DirectoryEntry Implements IDirectory.GetAvailableEntry |
141 | 192 | Dim Buffer(10) As Byte |
142 | 193 |
|
|
157 | 208 | Return Nothing |
158 | 209 | End Function |
159 | 210 |
|
160 | | - Public Function GetAvailableFileName(FileName As String, UseNTExtensions As Boolean, Optional CurrentIndex As Integer = -1) As String Implements IDirectory.GetAvailableFileName |
| 211 | + Public Function GetAvailableFileName(FileName As String, Optional CurrentIndex As Integer = -1) As String Implements IDirectory.GetAvailableFileName |
| 212 | + Dim FileParts = SplitFilename(FileName) |
| 213 | + |
| 214 | + Dim NewFileName As String = FileName |
| 215 | + Dim Index As UInteger = 1 |
| 216 | + |
| 217 | + Do While FindFileName(NewFileName, True, CurrentIndex) > -1 |
| 218 | + NewFileName = CombineFileParts(FileParts.Name & " (" & Index & ")", FileParts.Extension) |
| 219 | + Index += 1 |
| 220 | + Loop |
| 221 | + |
| 222 | + Return NewFileName |
| 223 | + End Function |
| 224 | + |
| 225 | + Public Function GetAvailableShortFileName(FileName As String, UseNTExtensions As Boolean, Optional CurrentIndex As Integer = -1) As String Implements IDirectory.GetAvailableShortFileName |
161 | 226 | Dim FileParts = SplitFilename(FileName) |
162 | 227 |
|
163 | 228 | Dim CleanFileName = DOSCleanFileName(FileParts.Name) |
|
179 | 244 | NewFileName = CombineFileParts(CleanFileName, CleanExtension) |
180 | 245 | End If |
181 | 246 |
|
182 | | - Do While GetFileIndex(NewFileName, True, CurrentIndex) > -1 |
| 247 | + Do While FindShortFileName(NewFileName, True, CurrentIndex) > -1 |
183 | 248 | NewFileName = TruncateFileName(CleanFileName, CleanExtension, Checksum, Index, UseNTExtensions) |
184 | 249 | Index += 1 |
185 | 250 | Loop |
|
202 | 267 | Public Function GetFile(Index As UInteger) As DirectoryEntry Implements IDirectory.GetFile |
203 | 268 | Return _DirectoryEntries.Item(Index) |
204 | 269 | End Function |
205 | | - |
206 | | - Public Function GetFileIndex(FileBytes() As Byte, IncludeDirectories As Boolean, Optional SkipIndex As Integer = -1) As Integer Implements IDirectory.GetFileIndex |
207 | | - If _DirectoryData.EntryCount > 0 Then |
208 | | - For Counter As UInteger = 0 To _DirectoryData.EntryCount - 1 |
209 | | - If Counter <> SkipIndex Then |
210 | | - Dim File = _DirectoryEntries.Item(Counter) |
211 | | - If Not File.IsDeleted And Not File.IsVolumeName And (IncludeDirectories Or Not File.IsDirectory) Then |
212 | | - If FileBytes.CompareTo(File.FileNameWithExtension) Then |
213 | | - Return Counter |
214 | | - End If |
215 | | - End If |
216 | | - End If |
217 | | - Next |
218 | | - End If |
219 | | - |
220 | | - Return -1 |
221 | | - End Function |
222 | | - |
223 | | - Public Function GetFileIndex(Filename As String, IncludeDirectories As Boolean, Optional SkipIndex As Integer = -1) As Integer Implements IDirectory.GetFileIndex |
224 | | - If _DirectoryData.EntryCount > 0 Then |
225 | | - For Counter As UInteger = 0 To _DirectoryData.EntryCount - 1 |
226 | | - If Counter <> SkipIndex Then |
227 | | - Dim File = _DirectoryEntries.Item(Counter) |
228 | | - If Not File.IsDeleted And Not File.IsVolumeName And (IncludeDirectories Or Not File.IsDirectory) Then |
229 | | - If File.GetShortFileName = Filename Then |
230 | | - Return Counter |
231 | | - End If |
232 | | - End If |
233 | | - End If |
234 | | - Next |
235 | | - End If |
236 | | - |
237 | | - Return -1 |
238 | | - End Function |
239 | | - |
240 | 270 | Public Function GetIndex(DirectoryEntry As DirectoryEntry) As Integer Implements IDirectory.GetIndex |
241 | 271 | Return _DirectoryEntries.IndexOf(DirectoryEntry) |
242 | 272 | End Function |
|
0 commit comments