It is currently Sat May 18, 2013 11:43 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Packer Problem
PostPosted: Wed Apr 10, 2013 2:13 pm 
Offline
User
User

Joined: Tue Jun 21, 2011 6:11 pm
Posts: 38
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:
UseBriefLZPacker()

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


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:04 pm 
Online
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 8867
Location: France
It shouldn't be the case, if you can post a full snippet showing the problem, I will move that to the bug forum


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:23 pm 
Offline
User
User

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

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.

Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:28 pm 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1084
Location: Netherlands
Is the file located on the OSX volume or do you have a dual boot configuration and it is reading from the Windows volume ?

_________________
OS X 10.8.3, PB 5.11 x64


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:36 pm 
Offline
User
User

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


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:40 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4714
Location: Berlin - Germany
Code:
CreateDirectory("C:\TEMP")

This requires Adminprivilege! Why not using GetTemporaryDirectory()?

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Linux Mint 14 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:40 pm 
Offline
User
User

Joined: Tue Jun 21, 2011 6:11 pm
Posts: 38
The app is running in unicode mode. that means that all filenames are reading in unicode-mode. could be this a problem?


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:42 pm 
Offline
User
User

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


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:45 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4714
Location: Berlin - Germany
This is up to you, what of the path is added.

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Linux Mint 14 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:49 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1381
Location: Boston, MA
Is this a case of CR$ vs CRLF$ for the end of line?

_________________
To understand recursion, you must first understand recursion. ~ unknown
I never make stupid mistakes. Only very, very clever ones. ~ John Peel


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 3:54 pm 
Offline
User
User

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


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 4:07 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1381
Location: Boston, MA
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.

_________________
To understand recursion, you must first understand recursion. ~ unknown
I never make stupid mistakes. Only very, very clever ones. ~ John Peel


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 4:11 pm 
Offline
User
User

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


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 4:22 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 1381
Location: Boston, MA
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.

_________________
To understand recursion, you must first understand recursion. ~ unknown
I never make stupid mistakes. Only very, very clever ones. ~ John Peel


Top
 Profile  
 
 Post subject: Re: Packer Problem
PostPosted: Wed Apr 10, 2013 4:27 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Oct 09, 2007 2:15 am
Posts: 234
maybe this is an Endian Problem ? Big and little Endian.. the byteorder thing I mean...
I think Intel and Mac uses different.

_________________
English is not my native language...
ImageImageImage


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye