Packer Problem

Mac OSX specific forum
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Packer Problem

Post 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
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Packer Problem

Post 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
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: Packer Problem

Post 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

Last edited by delikanli_19_82 on Wed Apr 10, 2013 3:32 pm, edited 1 time in total.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Packer Problem

Post 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 ?
Windows (x64)
Raspberry Pi OS (Arm64)
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: Packer Problem

Post 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.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Packer Problem

Post by ts-soft »

Code: Select all

CreateDirectory("C:\TEMP")
This requires Adminprivilege! Why not using GetTemporaryDirectory()?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: Packer Problem

Post 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?
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: Packer Problem

Post 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?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Packer Problem

Post by ts-soft »

This is up to you, what of the path is added.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Packer Problem

Post by skywalk »

Is this a case of CR$ vs CRLF$ for the end of line?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: Packer Problem

Post 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.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Packer Problem

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
delikanli_19_82
User
User
Posts: 38
Joined: Tue Jun 21, 2011 6:11 pm

Re: Packer Problem

Post 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?
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Packer Problem

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Packer Problem

Post by Bisonte »

maybe this is an Endian Problem ? Big and little Endian.. the byteorder thing I mean...
I think Intel and Mac uses different.
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Post Reply