Page 1 of 2

Packer Problem

Posted: Wed Apr 10, 2013 2:13 pm
by delikanli_19_82
hi guys,

i have no idea how to solve that problem.

i used the UseBriefLZPacker() to create an own format for my app. The app cross-works between windows and mac.

i have created several test-docs in my own format, which is in the reality only a file created with this packer. if i want to load them on os x, it cannot unpack the files. but if i create a new doc on the os x version of my app, it works. i see here is a incompatibility of the same packer in windows and mac. what can i do? i want to use this packer and no zip etc.

if i try to load a doc created on os x, on windows, it also does not work.

has anyone have an idea?

its just like this:

Code: Select all

UseBriefLZPacker()

If OpenPack(0, pth)
  If ExaminePack(0)
    While NextPackEntry(0)
      fn = targetLoc + PackEntryName(0)
     UncompressPackFile(0,fn)
    Wend
  EndIf
  ClosePack(0)  
EndIf

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:04 pm
by Fred
It shouldn't be the case, if you can post a full snippet showing the problem, I will move that to the bug forum

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:23 pm
by delikanli_19_82
hi fred,

the original code is very large.

if i run the packer and create a file on windows and read the file on windows, everything works fine. but if i read the file, which is created on windows, in mac, it doesn't work. if i run packer and create a file on mac and read it on mac, everything is also working fine. but if i try to read the file, which is created on mac, in windows, it also fail.

but i tested it only with the UseBriefLZPacker(). Now i will check it with zip.

thanks for your reply fred.

Code: Select all


Global myplace.s, mytemp.s
myplace = GetPathPart(ProgramFilename())

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Windows
    #sysexec = ".exe"
    #syschar = "\"
    ; ***
    If Right( myplace, 1 ) <> "\" : myplace + "\" : EndIf
    ; ***
    If FileSize("C:\TEMP") <> -2
      CreateDirectory("C:\TEMP")
    EndIf
    ; ***
    mytemp = "C:\TEMP\"
  CompilerDefault
    #sysexec = ""
    #syschar = "/"
    ; ***
    If Right( myplace, 1 ) <> "/" : myplace + "/" : EndIf
    ; ***
    mytemp = myplace + "temp"
    ; ***
    If FileSize(mytemp) <> -2
      CreateDirectory(mytemp)
    EndIf
    ; ***
    If Right( mytemp, 1 ) <> "/" : mytemp + "/" : EndIf
CompilerEndSelect

Procedure SaveMyWork( path.s )
   Define targetLoc.s = SaveFileRequester(...)
    ; ...
    UseBriefLZPacker()
If CreatePack(0, targetLoc)
  Foreach MyWorkFiles()
  AddPackFile( 0, MyWorkFiles(), GetFilePart( MyWorkFiles() ) ) 
  Next
  EndIf
  ClosePack(0)  
EndIf
    ; ...
EndProcedure

Procedure LoadMyWork( path.s )
   Define sourceLoc.s = OpenFileRequester(...)
   Define fn.s

UseBriefLZPacker()

If OpenPack(0, path)
  If ExaminePack(0)
    While NextPackEntry(0)
      fn = mytemp + PackEntryName(0)
     UncompressPackFile(0,fn)
    Wend
  EndIf
  ClosePack(0)  
EndIf

EndProcedure


Re: Packer Problem

Posted: Wed Apr 10, 2013 3:28 pm
by wilbert
Is the file located on the OSX volume or do you have a dual boot configuration and it is reading from the Windows volume ?

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:36 pm
by delikanli_19_82
no imagine,

you work on mac and start a new document in my app. think the app is something like msword. you wrote text and used images in the doc. now you save it. my app creates a pack-file with a text-file in it and a copy of all the images you used.

you copy the doc onto a usb-stick and stick it on your windows-notebook and want to open the doc with the same app on windows to continue your work.

here is the problem. the file cannot uncompressed correctly. if you save the doc in windows and reopen it on windows, everything is fine. if you save and reopen the doc on mac, everything is also fine. but if you save on windows and try to open in mac, or save on mac and want to reopen on windows, it fails.

there is no dualboot. its just a packed file. it contains all the files you used in the doc. that contains the images you used. settings and text will write in seperate temporary text files and will insert also to the pack-file.

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:40 pm
by ts-soft

Code: Select all

CreateDirectory("C:\TEMP")
This requires Adminprivilege! Why not using GetTemporaryDirectory()?

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:40 pm
by delikanli_19_82
The app is running in unicode mode. that means that all filenames are reading in unicode-mode. could be this a problem?

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:42 pm
by delikanli_19_82
hi ts-soft,

yes i could use this function. i will do. but the problem has nothing to do with this. because in the pack-file there will not insert the whole path to each file, or will it?

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:45 pm
by ts-soft
This is up to you, what of the path is added.

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:49 pm
by skywalk
Is this a case of CR$ vs CRLF$ for the end of line?

Re: Packer Problem

Posted: Wed Apr 10, 2013 3:54 pm
by delikanli_19_82
ts-soft

the files to add in a pack-file used from my app contains:

1) one settings file (text)
2) one or more text-files for doc-content
3) nothing, one or more image-files (png,jpeg)

thats all.

the user can save the packfile by the savefilerequester and open it with the openfilerequester.

skywalk:

i also believe, that the CR$ or CRLF$ could be the problem. but i am not sure and i have no idea how to solve it.

Re: Packer Problem

Posted: Wed Apr 10, 2013 4:07 pm
by skywalk
My suggestion is write your compressed data to a file but store the OS type in your pack header.
Then when you unpack you can query the OS and change the EOL characters if required.

Re: Packer Problem

Posted: Wed Apr 10, 2013 4:11 pm
by delikanli_19_82
i could add one more byte to the and of the packfile to notice on which os the file have been packed. sample:

0 = mac
1 = windows

but how can i change the EOL character when reading the packer? sample code maybe?

Re: Packer Problem

Posted: Wed Apr 10, 2013 4:22 pm
by skywalk
Since you are using addpackfile and uncompresspackfile, there is no OS or EOL awareness.
After you unpack a file, you would have to reread it and globally replace all EOL_MAC <--> EOL_WIN.
Not the best design, but it can work if this is your cross-platform problem.

Re: Packer Problem

Posted: Wed Apr 10, 2013 4:27 pm
by Bisonte
maybe this is an Endian Problem ? Big and little Endian.. the byteorder thing I mean...
I think Intel and Mac uses different.