Jump to content

ZIP UDF (zipfldr.dll library)


wraithdu
 Share

Recommended Posts

The error returned from _Zip_InternalDelete is different than the other functions (hence marked as internal). In this case, it means that the file was not deleted. I'll look into this further tomorrow on some older XP machines here at work (all my main machines are Win7 now, as well as my home computers), and try and find out where exactly it is failing. Truthfully I need to add a bit more error checking in that function.

Is there a way to call _Zip_DeleteItem without a pop-up dialog confirming delete? I not sure where the prompt dialog originates is it the For $oVerb in $overbs loop?

Link to comment
Share on other sites

The zipfldr.dll library is invoked through the Shell.Application object. I only have the amount of control that is provided by the library. It does not implement everything available in the Shell.Application object. That's a round-about way of saying no, I can't prevent that popup... which is why I wrote the kludgy internal function. Review this thread please, as many questions like yours have been asked regarding the operation of the zipfldr library, esp relating to the available Flags options.

Link to comment
Share on other sites

Fuck me sideways.

This is going to take a while to fix. The real problem is that XP's implementation of the zipfldr library cannot walk sub directories automatically. So you can't do $obj.NameSpace("...\file.zip\some\sub\dir"). Which means I have to do it manually with loops of NameSpace, ParseName, and GetFolder. FUCK.

Link to comment
Share on other sites

  • Moderators

wraithdu,

After that last post I presume we are correct in thinking that you are slightly miffed? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

It probably doesn't help matters but I don't envy you at all wraithdu! :)

Amat Victoria Curam

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I'm not feeling very victorious, even though I felt fairly prepared when originally re-writing this one... just goes to show...

So I think I fixed everything but the InternalDelete function. The point of this function, while kludgy, was to non-interactively delete files from archives. The idea was to create a temp directory then move the files out of the archive with the MoveHere method. This works great on Win7, but fails on WinXP. This means don't try to overwrite files in archives on XP, it will fail with an error. Use the _Zip_DeleteItem function (interactive) first to remove the old files, then add the new ones. If anyone has any suggestions, please speak up, cause I'm out of ideas.

Everything else should work though now. I'll update the first post in a minute, so I'll need some testers.

Link to comment
Share on other sites

I'm not feeling very victorious, even though I felt fairly prepared when originally re-writing this one... just goes to show...

So I think I fixed everything but the InternalDelete function. The point of this function, while kludgy, was to non-interactively delete files from archives. The idea was to create a temp directory then move the files out of the archive with the MoveHere method. This works great on Win7, but fails on WinXP. This means don't try to overwrite files in archives on XP, it will fail with an error. Use the _Zip_DeleteItem function (interactive) first to remove the old files, then add the new ones. If anyone has any suggestions, please speak up, cause I'm out of ideas.

Everything else should work though now. I'll update the first post in a minute, so I'll need some testers.

Recompiled with new version. I am getting this error on execution on XP and Win7 machines.

Compressed (zipped) Folders Error

The specified directory C:\Documents and Settings\Administrator\Local Settings\Temp\~xcsofli.tmp\EventLogBkup is empty, so Compressed (zipped) Folders cannot add it to the archive.

After select OK the application just hangs.

Just started to look into the problem.

Rob

Edited by RobK
Link to comment
Share on other sites

I tested on XP with no errors. I'll need some code to reproduce and test against.

edit

n/m, I see the problem. And again, gonna be difficult to work around on XP. Essentially the zipfldr library is complaining when trying to add an empty directory (which is currently how it creates subdirs for files). Originally this was why I used the GUID type files to add directory structure then delete the temp files with _Zip_InternalDelete.

When I was testing I was using multiple subdirs, in which case this error doesn't appear. I guess it only appears on a single subdir level. Again, I can't think of a solutions on XP since the InternalDelete function doesn't work. The temp file deletion step would be interactive.

You can work around it for now by creating your directory structure somewhere then adding it to the zip.

Edited by wraithdu
Link to comment
Share on other sites

I'm gonna revert a few changes to reinstate the temp file creation/deletion some subdirs work again. As I mentioned, this will fail on XP, so you'll have to work around it on your end, sorry.

All I really want to know is how can I remove the GUID files from the zip? The internal delete fails and there is no way to delete without prompts from the _Zip_DeleteItem method.

Your advice is appreciated.

Rob

Link to comment
Share on other sites

Pretty simple, do not add items to subfolders using the $sDestDir parameter. Create your directory structure from the root on your local file system, create your files in that structure, then add the root directory to the root of the zip file ($sDestDir = ""). This way the AddItem function won't try to create any directory structure and will not create those temporary files.

Link to comment
Share on other sites

  • 2 months later...

I had a problem when attempting to use _Zip_List with the full pathname specified in a UNC format:

//hostname/directorypath/filename.zip

(instead of the usual drive letter because my multi-user application couldn't depend on the same drive mappings)

Fortunately all I had to do was to comment out this line in the ZIP.au3 UDF for _Zip_List:

If Not _IsFullPath($sZipFile) Then Return SetError(3, 0, 0)

and this accepted the UNC.

UNC is short for Universal Naming Convention or Uniform Naming Convention and explained here: http://en.wikipedia.org/wiki/Path_(computing)#POSIX_pathname_definition

Is there a neater way that will not negate the IsFullPath check please?

Link to comment
Share on other sites

Windows uses the double backslash to indicate a UNC path, not the forward slashes you have.

EDIT: I read on that linked page that it will accept the forward slashes in windows, but this XP system I'm on will not find a network share with forward slashes, but will find it with back slashes. YMMV

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Agreed.

So please may this correction be made to the ZIP.au3 which is successful? (thanks in anticipation)

; #FUNCTION# ====================================================================================================

; Name...........: _IsFullPath

; Description....: Determines if a given path is a fully qualified path (well, roughly...)

; Syntax.........: _IsFullPath($sPath)

; Parameters.....: $sPath - Path to check

;

; Return values..: Success - True

; Failure - False

; Author.........: torels

; Modified.......: Tippex/BrewManNH

; Remarks........: Windows UNC path inclusion

; Related........:

; Link...........:

; Example........:

; ===============================================================================================================

Func _IsFullPath($sPath)

If StringInStr($sPath, ":\") Then

Return True

ElseIf StringInStr($sPath, "\\") Then

Return True

Else

Return False

EndIf

EndFunc ;==>_IsFullPath

Link to comment
Share on other sites

  • 1 month later...

I can't get the basic example to work. I'm running XP Pro SP3.

Here's the code:

#include <_zip.au3>

; create a test directory
$dir = @DesktopDir & "\mydir"
DirCreate($dir)
; create some files
For $i = 1 To 3
    FileWrite($dir & "\file" & $i, "")
Next
; create the ZIP
$file = _Zip_Create(@DesktopDir & "\test.zip", 1)
ConsoleWrite("err: " & @error & @CRLF)
_Zip_AddItem($file, $dir)
ConsoleWrite("err: " & @error & @CRLF)
; add it to a subdir
_Zip_AddItem($file, $dir, "dir1\dir2")
ConsoleWrite("err: " & @error & @CRLF)
; remove dir
DirRemove($dir, 1)

When I run this, I get the error message:

(...my include path here...)\_zip.au3 (131) : Error in expression.:

Until IsObj($oNS.ParseName($sNameOnly))

Until IsObj(^ ERROR

I haven't made any changes to the UDF. I've been looking on MSDN to figure out if there's something wrong with the way ParseName is being called here, but I haven't had any luck so far. Any ideas?

Edited by sigil
Link to comment
Share on other sites

Are you sure you have a full copy of the UDF, and not a copy/paste error? Other than that I'll need a lot more info, as that example works for me.

Additionally, start reading from post #95 about problems adding files to subdirs on WinXP.

Link to comment
Share on other sites

Are you sure you have a full copy of the UDF, and not a copy/paste error?

I copied the UDF today from what you have in post #1. Is there a more current version?

Other than that I'll need a lot more info, as that example works for me.

What other info would be most helpful?

I'm using AutoIt 3.3.6.1.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...