[BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

Tim Oesterreich

Hello all,

 

|package folder|

 

“Name of the Monticello-package that should be archived”

package := 'SWAProject'.

“Name of the resources folder in Contents/Resources/”

folder := 'SWA-Resources'.

 

zip := ZipArchive new.

mczStream := RWBinaryOrTextStream on: (String new: 10000).

workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).

version := workingCopy newVersion fileOutOn: mczStream.

(zip addString: mczStream contents as: package, '.mcz') desiredCompressionLevel: 0.

zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:

    Smalltalk imagePath , FileDirectory slash , folder].

zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package, '.mcz''.

(self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f | self

    extractMember: f].' as: 'install/preamble'.

zip writeToFileNamed: package , '.sar'.

 

This code should create a SAR-Archive from a Monticello-Package including all resources in the specified folder

However it throws the error “File not in Directory: SWA-Resources#” on a Windows-System, while working fine on a Mac.

It seems like there is an issue with the handling of platform-dependent directory seperators  (\ on Windows, / on UNIX).

 

Best

-Tim

 



tty
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

tty
W/o testing it, I noticed that you have a forward slash in 


FileDirectory slash , '*.*'') do: [ :f | self

  extractMember: f].' as: 'install/preamble'.  <---------------------should this be FileDirectory slash? 

cheers


---- On Thu, 22 Jan 2015 15:22:25 -0500 Tim Oesterreich <[hidden email]> wrote ----

Hello all,

 

|package folder|

 

“Name of the Monticello-package that should be archived”

package := 'SWAProject'.

“Name of the resources folder in Contents/Resources/”

folder := 'SWA-Resources'.

 

zip := ZipArchive new.

mczStream := RWBinaryOrTextStream on: (String new: 10000).

workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).

version := workingCopy newVersion fileOutOn: mczStream.

(zip addString: mczStream contents as: package, '.mcz') desiredCompressionLevel: 0.

zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:

    Smalltalk imagePath , FileDirectory slash , folder].

zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package, '.mcz''.

(self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f | self

    extractMember: f].' as: 'install/preamble'.

zip writeToFileNamed: package , '.sar'.

 

This code should create a SAR-Archive from a Monticello-Package including all resources in the specified folder

However it throws the error “File not in Directory: SWA-Resources#” on a Windows-System, while working fine on a Mac.

It seems like there is an issue with the handling of platform-dependent directory seperators  (\ on Windows, / on UNIX).

 

Best

-Tim

 





Reply | Threaded
Open this post in threaded view
|

AW: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

Tim Oesterreich

No that’s not it.
The error occurs at
                “zip addTree:match:”

 

Von: [hidden email] [mailto:[hidden email]ion.org] Im Auftrag von gettimothy
Gesendet: Thursday, 22 January, 2015 23:23
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

 

W/o testing it, I noticed that you have a forward slash in 

 

 

FileDirectory slash , '*.*'') do: [ :f | self

  extractMember: f].' as: 'install/preamble'.  <---------------------should this be FileDirectory slash? 

 

cheers

 


---- On Thu, 22 Jan 2015 15:22:25 -0500 Tim Oesterreich <[hidden email]> wrote ----

Hello all,

 

|package folder|

 

“Name of the Monticello-package that should be archived”

package := 'SWAProject'.

“Name of the resources folder in Contents/Resources/”

folder := 'SWA-Resources'.

 

zip := ZipArchive new.

mczStream := RWBinaryOrTextStream on: (String new: 10000).

workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).

version := workingCopy newVersion fileOutOn: mczStream.

(zip addString: mczStream contents as: package, '.mcz') desiredCompressionLevel: 0.

zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:

    Smalltalk imagePath , FileDirectory slash , folder].

zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package, '.mcz''.

(self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f | self

    extractMember: f].' as: 'install/preamble'.

zip writeToFileNamed: package , '.sar'.

 

This code should create a SAR-Archive from a Monticello-Package including all resources in the specified folder

However it throws the error “File not in Directory: SWA-Resources#” on a Windows-System, while working fine on a Mac.

It seems like there is an issue with the handling of platform-dependent directory seperators  (\ on Windows, / on UNIX).

 

Best

-Tim

 

 

 

 



Reply | Threaded
Open this post in threaded view
|

Re: [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

Tobias Pape
Hi

previously today I debugged the error together with Tim.
The culprit seems to be in

ZipDirectoryMember>>localFileName: aString
1 | dir entry parent |
2 super localFileName: aString.
3 fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
4 parent := FileDirectory default.
5 (parent directoryExists: fileName) ifTrue: [
6 dir := FileDirectory on: (parent fullNameFor: fileName).
7 entry := dir directoryEntry.
8 self setLastModFileDateTimeFrom: entry modificationTime
9 ]

the problematic messages are #directoryExists: (5) and #fullNameFor: (6),
because on Windows, `parent` is a DosFileDirectory (w/ pathDelemiter == $\)
but line 3 and super (2, ArchiveMember>>#localFileName: (super of ZipDirectoryMember)
force $/ at the end of the string.

ArchiveMember>>localFileName: aString
        "Set my internal filename.
        Returns the (possibly new) filename.
        aString will be translated from local FS format into Unix format."

        ^fileName := aString copyReplaceAll: FileDirectory slash with: '/'.

so, if `aString` above is 'Resources', it is forced to be

'Resources/', which DosFileDirectory “sanitizes” to 'Resources#', which does
not exists...

Best
        -Tobias



On 23.01.2015, at 00:02, Tim Oesterreich <[hidden email]> wrote:

> No that’s not it.
> The error occurs at
>                 “zip addTree:match:”
>  
> Von: [hidden email] [mailto:[hidden email]] Im Auftrag vongettimothy
> Gesendet: Thursday, 22 January, 2015 23:23
> An: The general-purpose Squeak developers list
> Betreff: Re: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows
>  
> W/o testing it, I noticed that you have a forward slash in
>  
>  
> FileDirectory slash , '*.*'') do: [ :f | self
>
>   extractMember: f].' as: 'install/preamble'.  <---------------------should this be FileDirectory slash?
>  
> cheers
>  
>
> ---- On Thu, 22 Jan 2015 15:22:25 -0500 Tim Oesterreich <[hidden email]> wrote ----
> Hello all,
>
>  
>
> |package folder|
>
>  
>
> “Name of the Monticello-package that should be archived”
>
> package := 'SWAProject'.
>
> “Name of the resources folder in Contents/Resources/”
>
> folder := 'SWA-Resources'.
>
>  
>
> zip := ZipArchive new.
>
> mczStream := RWBinaryOrTextStream on: (String new: 10000).
>
> workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).
>
> version := workingCopy newVersion fileOutOn: mczStream.
>
> (zip addString: mczStream contents as: package, '.mcz') desiredCompressionLevel: 0.
>
> zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:
>
>     Smalltalk imagePath , FileDirectory slash , folder].
>
> zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package, '.mcz''.
>
> (self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f | self
>
>     extractMember: f].' as: 'install/preamble'.
>
> zip writeToFileNamed: package , '.sar'.
>
>  
>
> This code should create a SAR-Archive from a Monticello-Package including all resources in the specified folder
>
> However it throws the error “File not in Directory: SWA-Resources#” on a Windows-System, while working fine on a Mac.
>
> It seems like there is an issue with the handling of platform-dependent directory seperators  (\ on Windows, / on UNIX).
>
>  
>
> Best
>
> -Tim




signature.asc (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

David T. Lewis
I do not have a Windows machine handy to check this, but it sounds to me
like you and Tim are closing in on the problem. If I remember right, the
zip archive uses '/' internally as a path separator, regardless of the
conventions of the local file system. A DosFileDirectory would quite rightly
use the path separator conventions for a DOS (Windows) file system, so the
path separator would be '\'. It would not be right to mix the two conventions.

>From your description below, it looks like ZipDirectoryMemory>>localFileName:
is trying to mix up the zip path separator conventions with the host
file system conventions. That is wrong, but apparently it works by accident
on Unix based systems.

If you can fix this so that it works properly on Windows, then it will
probably also work on Unix (and OS X) based systems. Most likely it will
be necessary to figure out two different path strings, one for the path
name on the local (DOS/Windows) file system, and another to represent
that same path name using the zip member conventions (which happen to
be based on Unix file system path names).

I think that this illustrates the importance of testing Squeak on a
variety of platforms :-)

Dave


I guess that the "parent fullNameFor: localFileSystemPath" should be using
a localFileSystemPath with the loc


On Fri, Jan 23, 2015 at 12:29:16AM +0100, Tobias Pape wrote:

> Hi
>
> previously today I debugged the error together with Tim.
> The culprit seems to be in
>
> ZipDirectoryMember>>localFileName: aString
> 1 | dir entry parent |
> 2 super localFileName: aString.
> 3 fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
> 4 parent := FileDirectory default.
> 5 (parent directoryExists: fileName) ifTrue: [
> 6 dir := FileDirectory on: (parent fullNameFor: fileName).
> 7 entry := dir directoryEntry.
> 8 self setLastModFileDateTimeFrom: entry modificationTime
> 9 ]
>
> the problematic messages are #directoryExists: (5) and #fullNameFor: (6),
> because on Windows, `parent` is a DosFileDirectory (w/ pathDelemiter == $\)
> but line 3 and super (2, ArchiveMember>>#localFileName: (super of ZipDirectoryMember)
> force $/ at the end of the string.
>
> ArchiveMember>>localFileName: aString
> "Set my internal filename.
> Returns the (possibly new) filename.
> aString will be translated from local FS format into Unix format."
>
> ^fileName := aString copyReplaceAll: FileDirectory slash with: '/'.
>
> so, if `aString` above is 'Resources', it is forced to be
>
> 'Resources/', which DosFileDirectory ?sanitizes? to 'Resources#', which does
> not exists...
>
> Best
> -Tobias
>
>
>
> On 23.01.2015, at 00:02, Tim Oesterreich <[hidden email]> wrote:
>
> > No that?s not it.
> > The error occurs at
> >                 ?zip addTree:match:?
> >  
> > Von: [hidden email] [mailto:[hidden email]] Im Auftrag vongettimothy
> > Gesendet: Thursday, 22 January, 2015 23:23
> > An: The general-purpose Squeak developers list
> > Betreff: Re: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows
> >  
> > W/o testing it, I noticed that you have a forward slash in
> >  
> >  
> > FileDirectory slash , '*.*'') do: [ :f | self
> >
> >   extractMember: f].' as: 'install/preamble'.  <---------------------should this be FileDirectory slash?
> >  
> > cheers
> >  
> >
> > ---- On Thu, 22 Jan 2015 15:22:25 -0500 Tim Oesterreich <[hidden email]> wrote ----
> > Hello all,
> >
> >  
> >
> > |package folder|
> >
> >  
> >
> > ?Name of the Monticello-package that should be archived?
> >
> > package := 'SWAProject'.
> >
> > ?Name of the resources folder in Contents/Resources/?
> >
> > folder := 'SWA-Resources'.
> >
> >  
> >
> > zip := ZipArchive new.
> >
> > mczStream := RWBinaryOrTextStream on: (String new: 10000).
> >
> > workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).
> >
> > version := workingCopy newVersion fileOutOn: mczStream.
> >
> > (zip addString: mczStream contents as: package, '.mcz') desiredCompressionLevel: 0.
> >
> > zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:
> >
> >     Smalltalk imagePath , FileDirectory slash , folder].
> >
> > zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package, '.mcz''.
> >
> > (self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f | self
> >
> >     extractMember: f].' as: 'install/preamble'.
> >
> > zip writeToFileNamed: package , '.sar'.
> >
> >  
> >
> > This code should create a SAR-Archive from a Monticello-Package including all resources in the specified folder
> >
> > However it throws the error ?File not in Directory: SWA-Resources#? on a Windows-System, while working fine on a Mac.
> >
> > It seems like there is an issue with the handling of platform-dependent directory seperators  (\ on Windows, / on UNIX).
> >
> >  
> >
> > Best
> >
> > -Tim
>
>



>


Reply | Threaded
Open this post in threaded view
|

Re: [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

David T. Lewis
In reply to this post by Tim Oesterreich
Hi Tim and Tobias,

I put a proposed fix for this in the inbox.

The update is:

ZipDirectoryMember>>localFileName: aString
        | dir entry parent fsPath |
        super localFileName: aString.
        fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
        parent := FileDirectory default.
        aString last = parent pathNameDelimiter
                ifTrue: [fsPath := parent fullNameFor: aString]
                ifFalse: [fsPath := parent fullNameFor: aString, parent slash].
        (parent directoryExists: fsPath) ifTrue: [
                dir := FileDirectory on: fsPath.
                entry := dir directoryEntry.
                self setLastModFileDateTimeFrom: entry modificationTime
        ]


This separates the host file system test (Windows in the case) from
the path naming in the zip archive. It also expands the path name to
be fully qualified ("C:\foo\bar" not just "bar") because this is important
on Windows and also should work on Unix.

Please give this a try and see if it solves the problem for you. If
nobody complains, I'll move it to trunk in a day or so.

Dave



On Thu, Jan 22, 2015 at 09:22:25PM +0100, Tim Oesterreich wrote:

> Hello all,
>
>  
>
> |package folder|
>
>  
>
> "Name of the Monticello-package that should be archived"
>
> package := 'SWAProject'.
>
> "Name of the resources folder in Contents/Resources/"
>
> folder := 'SWA-Resources'.
>
>  
>
> zip := ZipArchive new.
>
> mczStream := RWBinaryOrTextStream on: (String new: 10000).
>
> workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).
>
> version := workingCopy newVersion fileOutOn: mczStream.
>
> (zip addString: mczStream contents as: package, '.mcz')
> desiredCompressionLevel: 0.
>
> zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:
>
>     Smalltalk imagePath , FileDirectory slash , folder].
>
> zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package,
> '.mcz''.
>
> (self membersMatching: ''' , folder , FileDirectory slash , '*.*'') do: [ :f
> | self
>
>     extractMember: f].' as: 'install/preamble'.
>
> zip writeToFileNamed: package , '.sar'.
>
>  
>
> This code should create a SAR-Archive from a Monticello-Package including
> all resources in the specified folder
>
> However it throws the error "File not in Directory: SWA-Resources#" on a
> Windows-System, while working fine on a Mac.
>
> It seems like there is an issue with the handling of platform-dependent
> directory seperators  (\ on Windows, / on UNIX).
>
>  
>
> Best
>
> -Tim
>
>  
>

>


Reply | Threaded
Open this post in threaded view
|

AW: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

Tim Oesterreich
Hi Dave,

this did fix the problem. (Tested on Windows. I'm assuming it doesn't
suddenly crash on Unix now ;) )

Thank you!

Tim

-----Ursprüngliche Nachricht-----
Von: [hidden email]
[mailto:[hidden email]] Im Auftrag von David
T. Lewis
Gesendet: Saturday, 24 January, 2015 1:43
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while
trying to create a SAR-archive on Windows

Hi Tim and Tobias,

I put a proposed fix for this in the inbox.

The update is:

ZipDirectoryMember>>localFileName: aString
        | dir entry parent fsPath |
        super localFileName: aString.
        fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
        parent := FileDirectory default.
        aString last = parent pathNameDelimiter
                ifTrue: [fsPath := parent fullNameFor: aString]
                ifFalse: [fsPath := parent fullNameFor: aString, parent
slash].
        (parent directoryExists: fsPath) ifTrue: [
                dir := FileDirectory on: fsPath.
                entry := dir directoryEntry.
                self setLastModFileDateTimeFrom: entry modificationTime
        ]


This separates the host file system test (Windows in the case) from the path
naming in the zip archive. It also expands the path name to be fully
qualified ("C:\foo\bar" not just "bar") because this is important on Windows
and also should work on Unix.

Please give this a try and see if it solves the problem for you. If nobody
complains, I'll move it to trunk in a day or so.

Dave



On Thu, Jan 22, 2015 at 09:22:25PM +0100, Tim Oesterreich wrote:

> Hello all,
>
>  
>
> |package folder|
>
>  
>
> "Name of the Monticello-package that should be archived"
>
> package := 'SWAProject'.
>
> "Name of the resources folder in Contents/Resources/"
>
> folder := 'SWA-Resources'.
>
>  
>
> zip := ZipArchive new.
>
> mczStream := RWBinaryOrTextStream on: (String new: 10000).
>
> workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).
>
> version := workingCopy newVersion fileOutOn: mczStream.
>
> (zip addString: mczStream contents as: package, '.mcz')
> desiredCompressionLevel: 0.
>
> zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:
>
>     Smalltalk imagePath , FileDirectory slash , folder].
>
> zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package,
> '.mcz''.
>
> (self membersMatching: ''' , folder , FileDirectory slash , '*.*'')
> do: [ :f
> | self
>
>     extractMember: f].' as: 'install/preamble'.
>
> zip writeToFileNamed: package , '.sar'.
>
>  
>
> This code should create a SAR-Archive from a Monticello-Package
> including all resources in the specified folder
>
> However it throws the error "File not in Directory: SWA-Resources#" on
> a Windows-System, while working fine on a Mac.
>
> It seems like there is an issue with the handling of
> platform-dependent directory seperators  (\ on Windows, / on UNIX).
>
>  
>
> Best
>
> -Tim
>
>  
>

>




Reply | Threaded
Open this post in threaded view
|

Re: [BUG] ERROR: File not in Directory: [...] while trying to create a SAR-archive on Windows

David T. Lewis
OK good. I tried it on Unix with your original example code, and that works
also. I will move the update from inbox to trunk.

Thanks,
Dave


On Sat, Jan 24, 2015 at 02:53:20AM +0100, Tim Oesterreich wrote:

> Hi Dave,
>
> this did fix the problem. (Tested on Windows. I'm assuming it doesn't
> suddenly crash on Unix now ;) )
>
> Thank you!
>
> Tim
>
> -----Urspr?ngliche Nachricht-----
> Von: [hidden email]
> [mailto:[hidden email]] Im Auftrag von David
> T. Lewis
> Gesendet: Saturday, 24 January, 2015 1:43
> An: The general-purpose Squeak developers list
> Betreff: Re: [squeak-dev] [BUG] ERROR: File not in Directory: [...] while
> trying to create a SAR-archive on Windows
>
> Hi Tim and Tobias,
>
> I put a proposed fix for this in the inbox.
>
> The update is:
>
> ZipDirectoryMember>>localFileName: aString
> | dir entry parent fsPath |
> super localFileName: aString.
> fileName last = $/ ifFalse: [ fileName := fileName, '/' ].
> parent := FileDirectory default.
> aString last = parent pathNameDelimiter
> ifTrue: [fsPath := parent fullNameFor: aString]
> ifFalse: [fsPath := parent fullNameFor: aString, parent
> slash].
> (parent directoryExists: fsPath) ifTrue: [
> dir := FileDirectory on: fsPath.
> entry := dir directoryEntry.
> self setLastModFileDateTimeFrom: entry modificationTime
> ]
>
>
> This separates the host file system test (Windows in the case) from the path
> naming in the zip archive. It also expands the path name to be fully
> qualified ("C:\foo\bar" not just "bar") because this is important on Windows
> and also should work on Unix.
>
> Please give this a try and see if it solves the problem for you. If nobody
> complains, I'll move it to trunk in a day or so.
>
> Dave
>
>
>
> On Thu, Jan 22, 2015 at 09:22:25PM +0100, Tim Oesterreich wrote:
> > Hello all,
> >
> >  
> >
> > |package folder|
> >
> >  
> >
> > "Name of the Monticello-package that should be archived"
> >
> > package := 'SWAProject'.
> >
> > "Name of the resources folder in Contents/Resources/"
> >
> > folder := 'SWA-Resources'.
> >
> >  
> >
> > zip := ZipArchive new.
> >
> > mczStream := RWBinaryOrTextStream on: (String new: 10000).
> >
> > workingCopy := MCWorkingCopy forPackage: (MCPackage new name: package).
> >
> > version := workingCopy newVersion fileOutOn: mczStream.
> >
> > (zip addString: mczStream contents as: package, '.mcz')
> > desiredCompressionLevel: 0.
> >
> > zip addTree: Smalltalk imagePath match: [:e | e fullName startsWith:
> >
> >     Smalltalk imagePath , FileDirectory slash , folder].
> >
> > zip addString:  'self fileInMonticelloZipVersionNamed: ''' , package,
> > '.mcz''.
> >
> > (self membersMatching: ''' , folder , FileDirectory slash , '*.*'')
> > do: [ :f
> > | self
> >
> >     extractMember: f].' as: 'install/preamble'.
> >
> > zip writeToFileNamed: package , '.sar'.
> >
> >  
> >
> > This code should create a SAR-Archive from a Monticello-Package
> > including all resources in the specified folder
> >
> > However it throws the error "File not in Directory: SWA-Resources#" on
> > a Windows-System, while working fine on a Mac.
> >
> > It seems like there is an issue with the handling of
> > platform-dependent directory seperators  (\ on Windows, / on UNIX).
> >
> >  
> >
> > Best
> >
> > -Tim
> >
> >  
> >
>
> >
>
>
>