Filename isWritable fails

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

Filename isWritable fails

Gruenewald, Tom

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

    | file a b aStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    ["ERROR_SHARING_VIOLATION (IO Error 32)"
    b delete]]
    ensure:
    [aStream close.
    a delete]

Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Filename isWritable fails

Holger Guhl
Tom,
is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says
isWritable
    "Answer true if file is writable by this user.
    Writable for a directory means that new files can be created or old ones renamed."
There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

hope that helps
Holger

Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

    | file a b aStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    ["ERROR_SHARING_VIOLATION (IO Error 32)"
    b delete]]
    ensure:
    [aStream close.
    a delete]

Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.

_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Filename isWritable fails

Boris Popov, DeepCove Labs (SNN)

Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.

 

-Boris

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Holger Guhl
Sent: 12 May 2011 07:33
To: Gruenewald, Tom
Cc: [hidden email]
Subject: Re: [vwnc] Filename isWritable fails

 

Tom,
is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says

isWritable
    "Answer true if file is writable by this user.
    Writable for a directory means that new files can be created or old ones renamed."

There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

hope that helps
Holger

Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

| file a b aStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.

[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
["ERROR_SHARING_VIOLATION (IO Error 32)"
b delete]]
ensure:
[aStream close.
a delete]


Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.


 
 
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Antwort: RE: Filename isWritable fails

Gruenewald, Tom

Hello Holger.
Yes. The code snippet should only show the problem.

So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?

    | file a b aStream bStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    [bStream := b writeStream.
    [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
    ensure:
    [aStream close.
    a delete]

Best regards,
Tom Grünewald


________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


Inactive hide details for "Boris Popov, DeepCove Labs" <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" <[hidden email]>



An


Kopie


Thema

    RE: [vwnc] Filename isWritable fails

Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.

-Boris

From: [hidden email] [[hidden email]] On Behalf Of Holger Guhl
Sent:
12 May 2011 07:33
To:
Gruenewald, Tom
Cc:
[hidden email]
Subject:
Re: [vwnc] Filename isWritable fails

Tom,
is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says

isWritable
"Answer true if file is writable by this user.
Writable for a directory means that new files can be created or old ones renamed."
There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

hope that helps
Holger

Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

| file a b aStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.


[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
["ERROR_SHARING_VIOLATION (IO Error 32)"
b delete]]
ensure:
[aStream close.
a delete]


Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email:
[hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


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

Re: Antwort: RE: Filename isWritable fails

Steven Kelly

On Windows, #isWritable doesn’t even go that far: look at the code for PCFilename>>isWritable. It just looks at the read-only flag, not ACL permissions.

 

For 7.7.1 there’s Resolution 99501, "UseWin32-ACL-Access to check file accessibility and permissions with MS Windows Access Control List (ACL)". If you request that from support, note that AFAIR it just gives you the mechanism to use ACLs via a DLL – actually changing #isWritable is left to you.

 

Steve

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Gruenewald, Tom
Sent: 12. toukokuuta 2011 16:30
To: Boris Popov, DeepCove Labs; Holger Guhl
Cc: [hidden email]
Subject: [vwnc] Antwort: RE: Filename isWritable fails

 

Hello Holger.
Yes. The code snippet should only show the problem.

So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?

| file a b aStream bStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.

[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
[bStream := b writeStream.
[bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
ensure:
[aStream close.
a delete]


Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


Inactive hide details for "Boris Popov, DeepCove Labs" <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" <[hidden email]>

"Boris Popov, DeepCove Labs" <[hidden email]>
Gesendet von: [hidden email]

12.05.2011 15:00

An

"Holger Guhl" <[hidden email]>, "Gruenewald, Tom" <[hidden email]>

Kopie

<[hidden email]>

Thema

RE: [vwnc] Filename isWritable fails

 


Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.

-Boris

From: [hidden email] [[hidden email]] On Behalf Of Holger Guhl
Sent:
12 May 2011 07:33
To:
Gruenewald, Tom
Cc:
[hidden email]
Subject:
Re: [vwnc] Filename isWritable fails


Tom,
is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says
isWritable
"Answer true if file is writable by this user.
Writable for a directory means that new files can be created or old ones renamed."
There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

hope that helps
Holger

Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

| file a b aStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.


[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
["ERROR_SHARING_VIOLATION (IO Error 32)"
b delete]]
ensure:
[aStream close.
a delete]


Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email:
[hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: RE: Filename isWritable fails

Holger Guhl
Steven is right. There are more things to consider when checking access rights.
I created Res99501 as part of another resolution to handle troubles with the non-native FileDialog. While navigating through Vista file systems, one could experience read access violations.
While I find that the VM primitives work acceptable - most of the time - (high speed but only basic check), it is clear that certain use cases need a highly reliable answer. The resolution is a good basis. The fact that you must integrate it yourself in your #isWritable variant is simply that Support must concentrate on concrete issues. It's not up to me to decide that *every* Smalltalk user needs an enhanced version.

In my first answer I omitted the ACL aspect because I did not want to overload the discussion. As far as Tom described it, we see a real file sharing conflict, and this cannot be handled with advanced ACL checks as implemented in Res99501.

Cheers,
Holger

Am 12.05.2011 16:34, schrieb Steven Kelly:

On Windows, #isWritable doesn’t even go that far: look at the code for PCFilename>>isWritable. It just looks at the read-only flag, not ACL permissions.

 

For 7.7.1 there’s Resolution 99501, "UseWin32-ACL-Access to check file accessibility and permissions with MS Windows Access Control List (ACL)". If you request that from support, note that AFAIR it just gives you the mechanism to use ACLs via a DLL – actually changing #isWritable is left to you.

 

Steve

 

From: [hidden email] [[hidden email]] On Behalf Of Gruenewald, Tom
Sent: 12. toukokuuta 2011 16:30
To: Boris Popov, DeepCove Labs; Holger Guhl
Cc: [hidden email]
Subject: [vwnc] Antwort: RE: Filename isWritable fails

 

Hello Holger.
Yes. The code snippet should only show the problem.

So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?

| file a b aStream bStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.

[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
[bStream := b writeStream.
[bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
ensure:
[aStream close.
a delete]


Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


Inactive
              hide details for "Boris Popov, DeepCove Labs"
              <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" [hidden email]

"Boris Popov, DeepCove Labs" [hidden email]
Gesendet von: [hidden email]

12.05.2011 15:00

An

"Holger Guhl" [hidden email], "Gruenewald, Tom" [hidden email]

Kopie

[hidden email]

Thema

RE: [vwnc] Filename isWritable fails

 


Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.

-Boris

From: [hidden email] [[hidden email]] On Behalf Of Holger Guhl
Sent:
12 May 2011 07:33
To:
Gruenewald, Tom
Cc:
[hidden email]
Subject:
Re: [vwnc] Filename isWritable fails


Tom,
is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says
isWritable
"Answer true if file is writable by this user.
Writable for a directory means that new files can be created or old ones renamed."
There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

hope that helps
Holger

Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

| file a b aStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.


[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
["ERROR_SHARING_VIOLATION (IO Error 32)"
b delete]]
ensure:
[aStream close.
a delete]


Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email:
[hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.

_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: RE: Filename isWritable fails

Holger Guhl
In reply to this post by Gruenewald, Tom
Yes, that's the case: #isWritable checks the basic write-access permission without consulting the ACL (MS Access Control List). Effectively, that's not more than checking the file access flags. The #canBeWritten test goes a bit further, but also no ACL check there.
Even in Vista/Win7 with those tricky and obscure file system conditions you can go far with those basic checks, as long as the application deals with files in its "own directories". When it comes to navigating out of this scope you may easily encounter more file access violations.
But as already said: You are seeing a file sharing violation where ACL checks won't help.

Cheers
Holger

Am 12.05.2011 15:30, schrieb Gruenewald, Tom:

Hello Holger.
Yes. The code snippet should only show the problem.

So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?

    | file a b aStream bStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    [bStream := b writeStream.
    [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
    ensure:
    [aStream close.
    a delete]

Best regards,
Tom Grünewald


________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


Inactive hide
        details for "Boris Popov, DeepCove Labs"
        <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" [hidden email]



An


Kopie


Thema

    RE: [vwnc] Filename isWritable fails

Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.

-Boris

From: [hidden email] [[hidden email]] On Behalf Of Holger Guhl
Sent:
12 May 2011 07:33
To:
Gruenewald, Tom
Cc:
[hidden email]
Subject:
Re: [vwnc] Filename isWritable fails

Tom,
is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says

isWritable
"Answer true if file is writable by this user.
Writable for a directory means that new files can be created or old ones renamed."
There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

hope that helps
Holger

Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

Hello forum.
Is #isWritable not the appropriate test method to check if a file can be deleted?
I get an error sharing violation.

| file a b aStream |
file := 'c:\foo.txt'.
a := file asFilename.
aStream := a writeStream.


[b := file asFilename.
(b exists and: [b isWritable])
ifTrue:
["ERROR_SHARING_VIOLATION (IO Error 32)"
b delete]]
ensure:
[aStream close.
a delete]


Thank you for you answers.

Best regards,
Tom Grünewald

________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email:
[hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346


----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: RE: Filename isWritable fails

Mark Pirogovsky-3
In reply to this post by Holger Guhl
Does anyone know how to get this fix ?

I tried to download it form the Cincom Support Web, but the FTP portion
does not allow me to change dir to the "VisualWorks" and fails with the
500 error.

I can go to most of the other folders there but VisualWorks and
VisualSmalltalk ???

--Mark

Holger Guhl wrote:

> Steven is right. There are more things to consider when checking
> access rights.
> I created Res99501 as part of another resolution to handle troubles
> with the non-native FileDialog. While navigating through Vista file
> systems, one could experience read access violations.
> While I find that the VM primitives work acceptable - most of the time
> - (high speed but only basic check), it is clear that certain use
> cases need a highly reliable answer. The resolution is a good basis.
> The fact that you must integrate it yourself in your #isWritable
> variant is simply that Support must concentrate on concrete issues.
> It's not up to me to decide that *every* Smalltalk user needs an
> enhanced version.
>
> In my first answer I omitted the ACL aspect because I did not want to
> overload the discussion. As far as Tom described it, we see a real
> file sharing conflict, and this cannot be handled with advanced ACL
> checks as implemented in Res99501.
>
> Cheers,
> Holger
>
> Am 12.05.2011 16:34, schrieb Steven Kelly:
>>
>> On Windows, #isWritable doesn’t even go that far: look at the code
>> for PCFilename>>isWritable. It just looks at the read-only flag, not
>> ACL permissions.
>>
>> For 7.7.1 there’s Resolution 99501, "UseWin32-ACL-Access to check
>> file accessibility and permissions with MS Windows Access Control
>> List (ACL)". If you request that from support, note that AFAIR it
>> just gives you the mechanism to use ACLs via a DLL – actually
>> changing #isWritable is left to you.
>>
>> Steve
>>
>> *From:* [hidden email] [mailto:[hidden email]]
>> *On Behalf Of *Gruenewald, Tom
>> *Sent:* 12. toukokuuta 2011 16:30
>> *To:* Boris Popov, DeepCove Labs; Holger Guhl
>> *Cc:* [hidden email]
>> *Subject:* [vwnc] Antwort: RE: Filename isWritable fails
>>
>> Hello Holger.
>> Yes. The code snippet should only show the problem.
>>
>> So #isWritable tells if the active user has the common OS write
>> permission for a file and not if the file is writable in runtime?
>>
>> | file a b aStream bStream |
>> file := 'c:\foo.txt'.
>> a := file asFilename.
>> aStream := a writeStream.
>>
>> [b := file asFilename.
>> (b exists and: [b isWritable])
>> ifTrue:
>> [bStream := b writeStream.
>> [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
>> ensure:
>> [aStream close.
>> a delete]
>>
>>
>> Best regards,
>> Tom Grünewald
>>
>> ________
>>
>> Carl Zeiss Industrielle Messtechnik GmbH
>> Softwareentwicklung/Software Development
>>
>> T o m G r ü n e w a l d
>>
>> 73446 Oberkochen, Germany
>> tel: +49.7364.20-8541
>> fax: +49.7364.20-4800
>> email: [hidden email]
>> http://www.zeiss.de/imt
>>
>> Carl Zeiss Industrielle Messtechnik GmbH
>> Carl–Zeiss–Straße 22, 73447 Oberkochen
>> Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
>> Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
>> Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
>> Handelsregister: Amtsgericht Ulm, HRB 501561
>> USt–IdNr.: DE 811 515 346
>>
>> Inactive hide details for "Boris Popov, DeepCove Labs"
>> <[hidden email]>"Boris Popov, DeepCove Labs"
>> <[hidden email]>
>>
>> *"Boris Popov, DeepCove Labs" <[hidden email]>*
>> Gesendet von: [hidden email]
>>
>> 12.05.2011 15:00
>>
>>
>>
>> An
>>
>>
>>
>> "Holger Guhl" <[hidden email]>, "Gruenewald, Tom" <[hidden email]>
>>
>> Kopie
>>
>>
>>
>> <[hidden email]>
>>
>> Thema
>>
>>
>>
>> RE: [vwnc] Filename isWritable fails
>>
>>
>>
>>
>> Indeed, a lot of the queries against the file system will return
>> errors, even when seemingly innocuous, like #isDirectory, so you need
>> to make sure you have enough error handling in place to deal with
>> these errors.
>>
>> -Boris
>>
>> *From:* [hidden email] [mailto:[hidden email]]
>> *On Behalf Of *Holger Guhl*
>> Sent:* 12 May 2011 07:33*
>> To:* Gruenewald, Tom*
>> Cc:* [hidden email]*
>> Subject:* Re: [vwnc] Filename isWritable fails
>>
>> Tom,
>> is the code sample just for showing the problem? The code is itself
>> responsible for the failing delete request because it opens the file
>> with "a writeStream". Technically, this registers an open file handle
>> at the OS which then inhibits destroying the file from any process,
>> even if it's the same image that holds the open file. After closing
>> the file associated with "aStream", the delete request should work.
>> And no: #isWritable is not the full cover test which can tell in
>> advance whether #delete will be successful. The method comment says
>> isWritable
>> "Answer true if file is writable by this user.
>> Writable for a directory means that new files can be created or old
>> ones renamed."
>> There is a more through test called #canBeWritten, but again, it
>> cannot foresee whether the file is still in use by this or another
>> process.
>>
>> hope that helps
>> Holger
>>
>> Am 12.05.2011 12:53, schrieb Gruenewald, Tom:
>>
>> Hello forum.
>> Is #isWritable not the appropriate test method to check if a file can
>> be deleted?
>> I get an error sharing violation.
>> | file a b aStream |
>> file := 'c:\foo.txt'.
>> a := file asFilename.
>> aStream := a writeStream.
>>
>> [b := file asFilename.
>> (b exists and: [b isWritable])
>> ifTrue:
>> ["ERROR_SHARING_VIOLATION (IO Error 32)"
>> b delete]]
>> ensure:
>> [aStream close.
>> a delete]
>>
>> Thank you for you answers.
>>
>> Best regards,
>> Tom Grünewald
>>
>> ________
>>
>> Carl Zeiss Industrielle Messtechnik GmbH
>> Softwareentwicklung/Software Development
>>
>> T o m G r ü n e w a l d
>>
>> 73446 Oberkochen, Germany
>> tel: +49.7364.20-8541
>> fax: +49.7364.20-4800
>> email: [hidden email] <mailto:[hidden email]>_
>> _http://www.zeiss.de/imt
>>
>> Carl Zeiss Industrielle Messtechnik GmbH
>> Carl–Zeiss–Straße 22, 73447 Oberkochen
>> Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
>> Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
>> Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
>> Handelsregister: Amtsgericht Ulm, HRB 501561
>> USt–IdNr.: DE 811 515 346
>>
>> ----------------------------------------
>> This message is intended for a particular addressee only and may
>> contain business or company secrets. If you have received this email
>> in error, please contact the sender and delete the message
>> immediately. Any use of this email, including saving, publishing,
>> copying, replication or forwarding of the message or the contents is
>> not permitted.
>>
>>
>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email] <mailto:[hidden email]>
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>>
>> ----------------------------------------
>> This message is intended for a particular addressee only and may
>> contain business or company secrets. If you have received this email
>> in error, please contact the sender and delete the message
>> immediately. Any use of this email, including saving, publishing,
>> copying, replication or forwarding of the message or the contents is
>> not permitted.
>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>      
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>    

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: RE: Filename isWritable fails

Steven Kelly
I emailed support and asked for it, and they sent it to me on CD. The reasons for lack of online access are presumably the same as the current lack of non-commercial and vw-dev downloads - US law. Cincom are working to get back to a more normal mode of distribution. I'm struggling to resist the obvious legal and ecological discussions, since this isn't the forum: I guess Cincom's hands are tied.

Steve

Mark Pirogovsky [mailto:[hidden email]] wrote:

> Does anyone know how to get this fix ?
>
> I tried to download it form the Cincom Support Web, but the FTP portion
> does not allow me to change dir to the "VisualWorks" and fails with the
> 500 error.
>
> I can go to most of the other folders there but VisualWorks and
> VisualSmalltalk ???
>
> --Mark
>
> Holger Guhl wrote:
> > Steven is right. There are more things to consider when checking
> > access rights.
> > I created Res99501 as part of another resolution to handle troubles
> > with the non-native FileDialog. While navigating through Vista file
> > systems, one could experience read access violations.
> > While I find that the VM primitives work acceptable - most of the
> time
> > - (high speed but only basic check), it is clear that certain use
> > cases need a highly reliable answer. The resolution is a good basis.
> > The fact that you must integrate it yourself in your #isWritable
> > variant is simply that Support must concentrate on concrete issues.
> > It's not up to me to decide that *every* Smalltalk user needs an
> > enhanced version.
> >
> > In my first answer I omitted the ACL aspect because I did not want to
> > overload the discussion. As far as Tom described it, we see a real
> > file sharing conflict, and this cannot be handled with advanced ACL
> > checks as implemented in Res99501.
> >
> > Cheers,
> > Holger
> >
> > Am 12.05.2011 16:34, schrieb Steven Kelly:
> >>
> >> On Windows, #isWritable doesn't even go that far: look at the code
> >> for PCFilename>>isWritable. It just looks at the read-only flag, not
> >> ACL permissions.
> >>
> >> For 7.7.1 there's Resolution 99501, "UseWin32-ACL-Access to check
> >> file accessibility and permissions with MS Windows Access Control
> >> List (ACL)". If you request that from support, note that AFAIR it
> >> just gives you the mechanism to use ACLs via a DLL - actually
> >> changing #isWritable is left to you.
> >>
> >> Steve
> >>
> >> *From:* [hidden email] [mailto:[hidden email]]
> >> *On Behalf Of *Gruenewald, Tom
> >> *Sent:* 12. toukokuuta 2011 16:30
> >> *To:* Boris Popov, DeepCove Labs; Holger Guhl
> >> *Cc:* [hidden email]
> >> *Subject:* [vwnc] Antwort: RE: Filename isWritable fails
> >>
> >> Hello Holger.
> >> Yes. The code snippet should only show the problem.
> >>
> >> So #isWritable tells if the active user has the common OS write
> >> permission for a file and not if the file is writable in runtime?
> >>
> >> | file a b aStream bStream |
> >> file := 'c:\foo.txt'.
> >> a := file asFilename.
> >> aStream := a writeStream.
> >>
> >> [b := file asFilename.
> >> (b exists and: [b isWritable])
> >> ifTrue:
> >> [bStream := b writeStream.
> >> [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
> >> ensure:
> >> [aStream close.
> >> a delete]
> >>
> >>
> >> Best regards,
> >> Tom Grünewald
> >>
> >> ________
> >>
> >> Carl Zeiss Industrielle Messtechnik GmbH
> >> Softwareentwicklung/Software Development
> >>
> >> T o m G r ü n e w a l d
> >>
> >> 73446 Oberkochen, Germany
> >> tel: +49.7364.20-8541
> >> fax: +49.7364.20-4800
> >> email: [hidden email]
> >> http://www.zeiss.de/imt
> >>
> >> Carl Zeiss Industrielle Messtechnik GmbH
> >> Carl-Zeiss-Straße 22, 73447 Oberkochen
> >> Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
> >> Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
> >> Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
> >> Handelsregister: Amtsgericht Ulm, HRB 501561
> >> USt-IdNr.: DE 811 515 346
> >>
> >> Inactive hide details for "Boris Popov, DeepCove Labs"
> >> <[hidden email]>"Boris Popov, DeepCove Labs"
> >> <[hidden email]>
> >>
> >> *"Boris Popov, DeepCove Labs" <[hidden email]>*
> >> Gesendet von: [hidden email]
> >>
> >> 12.05.2011 15:00
> >>
> >>
> >>
> >> An
> >>
> >>
> >>
> >> "Holger Guhl" <[hidden email]>, "Gruenewald, Tom"
> <[hidden email]>
> >>
> >> Kopie
> >>
> >>
> >>
> >> <[hidden email]>
> >>
> >> Thema
> >>
> >>
> >>
> >> RE: [vwnc] Filename isWritable fails
> >>
> >>
> >>
> >>
> >> Indeed, a lot of the queries against the file system will return
> >> errors, even when seemingly innocuous, like #isDirectory, so you
> need
> >> to make sure you have enough error handling in place to deal with
> >> these errors.
> >>
> >> -Boris
> >>
> >> *From:* [hidden email] [mailto:[hidden email]]
> >> *On Behalf Of *Holger Guhl*
> >> Sent:* 12 May 2011 07:33*
> >> To:* Gruenewald, Tom*
> >> Cc:* [hidden email]*
> >> Subject:* Re: [vwnc] Filename isWritable fails
> >>
> >> Tom,
> >> is the code sample just for showing the problem? The code is itself
> >> responsible for the failing delete request because it opens the file
> >> with "a writeStream". Technically, this registers an open file
> handle
> >> at the OS which then inhibits destroying the file from any process,
> >> even if it's the same image that holds the open file. After closing
> >> the file associated with "aStream", the delete request should work.
> >> And no: #isWritable is not the full cover test which can tell in
> >> advance whether #delete will be successful. The method comment says
> >> isWritable
> >> "Answer true if file is writable by this user.
> >> Writable for a directory means that new files can be created or old
> >> ones renamed."
> >> There is a more through test called #canBeWritten, but again, it
> >> cannot foresee whether the file is still in use by this or another
> >> process.
> >>
> >> hope that helps
> >> Holger
> >>
> >> Am 12.05.2011 12:53, schrieb Gruenewald, Tom:
> >>
> >> Hello forum.
> >> Is #isWritable not the appropriate test method to check if a file
> can
> >> be deleted?
> >> I get an error sharing violation.
> >> | file a b aStream |
> >> file := 'c:\foo.txt'.
> >> a := file asFilename.
> >> aStream := a writeStream.
> >>
> >> [b := file asFilename.
> >> (b exists and: [b isWritable])
> >> ifTrue:
> >> ["ERROR_SHARING_VIOLATION (IO Error 32)"
> >> b delete]]
> >> ensure:
> >> [aStream close.
> >> a delete]
> >>
> >> Thank you for you answers.
> >>
> >> Best regards,
> >> Tom Grünewald
> >>
> >> ________
> >>
> >> Carl Zeiss Industrielle Messtechnik GmbH
> >> Softwareentwicklung/Software Development
> >>
> >> T o m G r ü n e w a l d
> >>
> >> 73446 Oberkochen, Germany
> >> tel: +49.7364.20-8541
> >> fax: +49.7364.20-4800
> >> email: [hidden email] <mailto:[hidden email]>_
> >> _http://www.zeiss.de/imt
> >>
> >> Carl Zeiss Industrielle Messtechnik GmbH
> >> Carl-Zeiss-Straße 22, 73447 Oberkochen
> >> Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
> >> Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
> >> Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
> >> Handelsregister: Amtsgericht Ulm, HRB 501561
> >> USt-IdNr.: DE 811 515 346
> >>
> >> ----------------------------------------
> >> This message is intended for a particular addressee only and may
> >> contain business or company secrets. If you have received this email
> >> in error, please contact the sender and delete the message
> >> immediately. Any use of this email, including saving, publishing,
> >> copying, replication or forwarding of the message or the contents is
> >> not permitted.
> >>
> >>
> >>
> >>
> >> _______________________________________________
> >> vwnc mailing list
> >> [hidden email] <mailto:[hidden email]>
> >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
> >>
> >>
> >>
> >> ----------------------------------------
> >> This message is intended for a particular addressee only and may
> >> contain business or company secrets. If you have received this email
> >> in error, please contact the sender and delete the message
> >> immediately. Any use of this email, including saving, publishing,
> >> copying, replication or forwarding of the message or the contents is
> >> not permitted.
> >>
> >>
> >> _______________________________________________
> >> vwnc mailing list
> >> [hidden email]
> >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
> >>
> >
> >
> > _______________________________________________
> > vwnc mailing list
> > [hidden email]
> > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
> >


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Filename isWritable fails

Gruenewald, Tom
In reply to this post by Holger Guhl

Hello Holger. Hello forum.
Thank you all for your answers.

I have played with my last code example. And now I am confused.

When I try to delete an already open file, I will get an error sharing violation. I totally agree with this behavior.
But I can write - from the outer scope - into the same file without any problem. I would expect also an error sharing violation here. But instead I get a messy output result.

    | file a b aStream bStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    [bStream := b readWriteStream.

    [bStream nextPutAll: 'Stream B: Hello World'.
    bStream flush.
    aStream cr.
    aStream nextPutAll: 'Stream A: Hello World'.
    aStream flush.
    bStream reset.
    (contents := bStream contents) isEmpty
    ifTrue: [Error raiseSignal: 'Empty file']
    ifFalse: [Transcript show: contents]]
    ensure: [bStream close]]]
    ensure:
    [aStream close.
    a delete]

The Transcript output is: "Stream B: Hello Worldld"

Why does no error sharing violation pop up here?

Best regards,
Tom Grünewald


________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346

Inactive hide details for Holger Guhl <holger@heeg.de>Holger Guhl <[hidden email]>



An


Kopie


Thema

    Re: Antwort: RE: [vwnc] Filename isWritable fails

Yes, that's the case: #isWritable checks the basic write-access permission without consulting the ACL (MS Access Control List). Effectively, that's not more than checking the file access flags. The #canBeWritten test goes a bit further, but also no ACL check there.
Even in Vista/Win7 with those tricky and obscure file system conditions you can go far with those basic checks, as long as the application deals with files in its "own directories". When it comes to navigating out of this scope you may easily encounter more file access violations.
But as already said: You are seeing a file sharing violation where ACL checks won't help.

Cheers
Holger

Am 12.05.2011 15:30, schrieb Gruenewald, Tom:

    Hello Holger.
    Yes. The code snippet should only show the problem.


    So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?


      | file a b aStream bStream |
      file := 'c:\foo.txt'.
      a := file asFilename.
      aStream := a writeStream.


      [b := file asFilename.
      (b exists and: [b isWritable])
      ifTrue:
      [bStream := b writeStream.
      [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
      ensure:
      [aStream close.
      a delete]

    Best regards,
    Tom Grünewald

    ________

    Carl Zeiss Industrielle Messtechnik GmbH
    Softwareentwicklung/Software Development

    T o m G r ü n e w a l d

    73446 Oberkochen, Germany
    tel: +49.7364.20-8541
    fax: +49.7364.20-4800
    email:
    [hidden email]
    http://www.zeiss.de/imt

    Carl Zeiss Industrielle Messtechnik GmbH
    Carl–Zeiss–Straße 22, 73447 Oberkochen
    Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
    Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
    Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
    Handelsregister: Amtsgericht Ulm, HRB 501561
    USt–IdNr.: DE 811 515 346


    Inactive hide
        details for "Boris Popov, DeepCove Labs"
        <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" [hidden email]

    An
    Kopie
    Thema
      RE: [vwnc] Filename isWritable fails

    Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.


    -Boris


    From:
    [hidden email] [[hidden email]] On Behalf Of Holger Guhl
    Sent:
    12 May 2011 07:33
    To:
    Gruenewald, Tom
    Cc:
    [hidden email]
    Subject:
    Re: [vwnc] Filename isWritable fails

    Tom,
    is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
    And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says

    isWritable
    "Answer true if file is writable by this user.
    Writable for a directory means that new files can be created or old ones renamed."

    There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

    hope that helps
    Holger

    Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

    Hello forum.
    Is #isWritable not the appropriate test method to check if a file can be deleted?
    I get an error sharing violation.
    | file a b aStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    ["ERROR_SHARING_VIOLATION (IO Error 32)"
    b delete]]
    ensure:
    [aStream close.
    a delete]


    Thank you for you answers.

    Best regards,
    Tom Grünewald

    ________

    Carl Zeiss Industrielle Messtechnik GmbH
    Softwareentwicklung/Software Development

    T o m G r ü n e w a l d

    73446 Oberkochen, Germany
    tel: +49.7364.20-8541
    fax: +49.7364.20-4800
    email:
    [hidden email]
    http://www.zeiss.de/imt

    Carl Zeiss Industrielle Messtechnik GmbH
    Carl–Zeiss–Straße 22, 73447 Oberkochen
    Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
    Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
    Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
    Handelsregister: Amtsgericht Ulm, HRB 501561
    USt–IdNr.: DE 811 515 346


    ----------------------------------------
    This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




    _______________________________________________
    vwnc mailing list

    [hidden email]
    http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



    ----------------------------------------
    This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


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

Re: Filename isWritable fails

Holger Guhl
That's the nature of files. It's allowed to open a file for writing from different processes. That's not a VisualWorks feature but allowed by the Operation System. It's up to programmers to make sure they don't create messy file contents.
Your example is of course destructive (as I assume that it should be for demo purpose). A frequent use case is a commonly used log file. If every process opens the file with #appendStream, you're pretty sure to prevent such a mess. The code for proper use is like this
file := 'dentalshare.log' asFilename appendStream.
...
[logging] whileTrue:
    ["log output example:"
    file print: 2; space; print: Timestamp now; cr; close]
That means: You open your file once and then do the logging. Each VisualWorks image with the same setup will append its output to the most recent file content.

Cheers
Holger

Am 13.05.2011 10:59, schrieb Gruenewald, Tom:

Hello Holger. Hello forum.
Thank you all for your answers.

I have played with my last code example. And now I am confused.

When I try to delete an already open file, I will get an error sharing violation. I totally agree with this behavior.
But I can write - from the outer scope - into the same file without any problem. I would expect also an error sharing violation here. But instead I get a messy output result.

    | file a b aStream bStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    [bStream := b readWriteStream.

    [bStream nextPutAll: 'Stream B: Hello World'.
    bStream flush.
    aStream cr.
    aStream nextPutAll: 'Stream A: Hello World'.
    aStream flush.
    bStream reset.
    (contents := bStream contents) isEmpty
    ifTrue: [Error raiseSignal: 'Empty file']
    ifFalse: [Transcript show: contents]]
    ensure: [bStream close]]]
    ensure:
    [aStream close.
    a delete]

The Transcript output is: "Stream B: Hello Worldld"

Why does no error sharing violation pop up here?

Best regards,
Tom Grünewald


________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346

Inactive hide
        details for Holger Guhl <holger@heeg.de>Holger Guhl [hidden email]



An


Kopie


Thema

    Re: Antwort: RE: [vwnc] Filename isWritable fails

Yes, that's the case: #isWritable checks the basic write-access permission without consulting the ACL (MS Access Control List). Effectively, that's not more than checking the file access flags. The #canBeWritten test goes a bit further, but also no ACL check there.
Even in Vista/Win7 with those tricky and obscure file system conditions you can go far with those basic checks, as long as the application deals with files in its "own directories". When it comes to navigating out of this scope you may easily encounter more file access violations.
But as already said: You are seeing a file sharing violation where ACL checks won't help.

Cheers
Holger

Am 12.05.2011 15:30, schrieb Gruenewald, Tom:

    Hello Holger.
    Yes. The code snippet should only show the problem.


    So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?


      | file a b aStream bStream |
      file := 'c:\foo.txt'.
      a := file asFilename.
      aStream := a writeStream.


      [b := file asFilename.
      (b exists and: [b isWritable])
      ifTrue:
      [bStream := b writeStream.
      [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
      ensure:
      [aStream close.
      a delete]

    Best regards,
    Tom Grünewald

    ________

    Carl Zeiss Industrielle Messtechnik GmbH
    Softwareentwicklung/Software Development

    T o m G r ü n e w a l d

    73446 Oberkochen, Germany
    tel: +49.7364.20-8541
    fax: +49.7364.20-4800
    email:
    [hidden email]
    http://www.zeiss.de/imt

    Carl Zeiss Industrielle Messtechnik GmbH
    Carl–Zeiss–Straße 22, 73447 Oberkochen
    Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
    Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
    Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
    Handelsregister: Amtsgericht Ulm, HRB 501561
    USt–IdNr.: DE 811 515 346


    Inactive hide details for "Boris Popov, DeepCove
          Labs" <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" [hidden email]

    An
    Kopie
    Thema
      RE: [vwnc] Filename isWritable fails

    Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.


    -Boris


    From:
    [hidden email] [[hidden email]] On Behalf Of Holger Guhl
    Sent:
    12 May 2011 07:33
    To:
    Gruenewald, Tom
    Cc:
    [hidden email]
    Subject:
    Re: [vwnc] Filename isWritable fails

    Tom,
    is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
    And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says

    isWritable
    "Answer true if file is writable by this user.
    Writable for a directory means that new files can be created or old ones renamed."

    There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

    hope that helps
    Holger

    Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

    Hello forum.
    Is #isWritable not the appropriate test method to check if a file can be deleted?
    I get an error sharing violation.
    | file a b aStream |
    file := 'c:\foo.txt'.
    a := file asFilename.
    aStream := a writeStream.

    [b := file asFilename.
    (b exists and: [b isWritable])
    ifTrue:
    ["ERROR_SHARING_VIOLATION (IO Error 32)"
    b delete]]
    ensure:
    [aStream close.
    a delete]


    Thank you for you answers.

    Best regards,
    Tom Grünewald

    ________

    Carl Zeiss Industrielle Messtechnik GmbH
    Softwareentwicklung/Software Development

    T o m G r ü n e w a l d

    73446 Oberkochen, Germany
    tel: +49.7364.20-8541
    fax: +49.7364.20-4800
    email:
    [hidden email]
    http://www.zeiss.de/imt

    Carl Zeiss Industrielle Messtechnik GmbH
    Carl–Zeiss–Straße 22, 73447 Oberkochen
    Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
    Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
    Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
    Handelsregister: Amtsgericht Ulm, HRB 501561
    USt–IdNr.: DE 811 515 346


    ----------------------------------------
    This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




    _______________________________________________
    vwnc mailing list

    [hidden email]
    http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



    ----------------------------------------
    This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Filename isWritable fails

Gruenewald, Tom

Hello Holger. Hello forum.
>> It's allowed to open a file for writing from different processes. That's not a VisualWorks feature but allowed by the Operation System. It's up to programmers to make sure they don't create messy file contents.
Just for my personal interest. How can I flag a file as locked for the OS? And will this lock automatically released after the program was finished?

Best regards,
Tom Grünewald


________

Carl Zeiss Industrielle Messtechnik GmbH
Softwareentwicklung/Software Development

T o m G r ü n e w a l d

73446 Oberkochen, Germany
tel: +49.7364.20-8541
fax: +49.7364.20-4800
email: [hidden email]
http://www.zeiss.de/imt

Carl Zeiss Industrielle Messtechnik GmbH
Carl–Zeiss–Straße 22, 73447 Oberkochen
Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
Handelsregister: Amtsgericht Ulm, HRB 501561
USt–IdNr.: DE 811 515 346

Inactive hide details for Holger Guhl <holger@heeg.de>Holger Guhl <[hidden email]>



An


Kopie


Thema

    Re: [vwnc] Filename isWritable fails

That's the nature of files. It's allowed to open a file for writing from different processes. That's not a VisualWorks feature but allowed by the Operation System. It's up to programmers to make sure they don't create messy file contents.
Your example is of course destructive (as I assume that it should be for demo purpose). A frequent use case is a commonly used log file. If every process opens the file with #appendStream, you're pretty sure to prevent such a mess. The code for proper use is like this

file := 'dentalshare.log' asFilename appendStream.
...
[logging] whileTrue:
["log output example:"
file print: 2; space; print: Timestamp now; cr; close]

That means: You open your file once and then do the logging. Each VisualWorks image with the same setup will append its output to the most recent file content.

Cheers
Holger

Am 13.05.2011 10:59, schrieb Gruenewald, Tom:

    Hello Holger. Hello forum.
    Thank you all for your answers.


    I have played with my last code example. And now I am confused.


    When I try to delete an already open file, I will get an error sharing violation. I totally agree with this behavior.
    But I can write - from the outer scope - into the same file without any problem. I would expect also an error sharing violation here. But instead I get a messy output result.

      | file a b aStream bStream |
      file := 'c:\foo.txt'.
      a := file asFilename.
      aStream := a writeStream.


      [b := file asFilename.
      (b exists and: [b isWritable])
      ifTrue:
      [bStream := b readWriteStream.


      [bStream nextPutAll: 'Stream B: Hello World'.
      bStream flush.
      aStream cr.
      aStream nextPutAll: 'Stream A: Hello World'.
      aStream flush.
      bStream reset.
      (contents := bStream contents) isEmpty
      ifTrue: [Error raiseSignal: 'Empty file']
      ifFalse: [Transcript show: contents]]
      ensure: [bStream close]]]
      ensure:
      [aStream close.
      a delete]

    The Transcript output is: "Stream B: Hello Worldld"


    Why does no error sharing violation pop up here?

    Best regards,
    Tom Grünewald

    ________

    Carl Zeiss Industrielle Messtechnik GmbH
    Softwareentwicklung/Software Development

    T o m G r ü n e w a l d

    73446 Oberkochen, Germany
    tel: +49.7364.20-8541
    fax: +49.7364.20-4800
    email:
    [hidden email]
    http://www.zeiss.de/imt

    Carl Zeiss Industrielle Messtechnik GmbH
    Carl–Zeiss–Straße 22, 73447 Oberkochen
    Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
    Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
    Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
    Handelsregister: Amtsgericht Ulm, HRB 501561
    USt–IdNr.: DE 811 515 346

    Inactive hide
        details for Holger Guhl <holger@heeg.de>Holger Guhl [hidden email]

    An
    Kopie
    Thema
      Re: Antwort: RE: [vwnc] Filename isWritable fails

    Yes, that's the case: #isWritable checks the basic write-access permission without consulting the ACL (MS Access Control List). Effectively, that's not more than checking the file access flags. The #canBeWritten test goes a bit further, but also no ACL check there.
    Even in Vista/Win7 with those tricky and obscure file system conditions you can go far with those basic checks, as long as the application deals with files in its "own directories". When it comes to navigating out of this scope you may easily encounter more file access violations.
    But as already said: You are seeing a file sharing violation where ACL checks won't help.

    Cheers
    Holger

    Am 12.05.2011 15:30, schrieb Gruenewald, Tom:

      Hello Holger.
      Yes. The code snippet should only show the problem.

      So #isWritable tells if the active user has the common OS write permission for a file and not if the file is writable in runtime?

        | file a b aStream bStream |
        file := 'c:\foo.txt'.
        a := file asFilename.
        aStream := a writeStream.

        [b := file asFilename.
        (b exists and: [b isWritable])
        ifTrue:
        [bStream := b writeStream.
        [bStream nextPutAll: 'Hello World'] ensure: [bStream close]]]
        ensure:
        [aStream close.
        a delete]

      Best regards,
      Tom Grünewald

      ________

      Carl Zeiss Industrielle Messtechnik GmbH
      Softwareentwicklung/Software Development

      T o m G r ü n e w a l d

      73446 Oberkochen, Germany
      tel: +49.7364.20-8541
      fax: +49.7364.20-4800
      email:
      [hidden email]
      http://www.zeiss.de/imt

      Carl Zeiss Industrielle Messtechnik GmbH
      Carl–Zeiss–Straße 22, 73447 Oberkochen
      Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
      Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
      Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
      Handelsregister: Amtsgericht Ulm, HRB 501561
      USt–IdNr.: DE 811 515 346


      Inactive hide details for "Boris Popov, DeepCove
          Labs" <boris@deepcovelabs.com>"Boris Popov, DeepCove Labs" [hidden email]
      An
      Kopie
      Thema
        RE: [vwnc] Filename isWritable fails

      Indeed, a lot of the queries against the file system will return errors, even when seemingly innocuous, like #isDirectory, so you need to make sure you have enough error handling in place to deal with these errors.

      -Boris


      From:
      [hidden email] [[hidden email]] On Behalf Of Holger Guhl
      Sent:
      12 May 2011 07:33
      To:
      Gruenewald, Tom
      Cc:
      [hidden email]
      Subject:
      Re: [vwnc] Filename isWritable fails

      Tom,
      is the code sample just for showing the problem? The code is itself responsible for the failing delete request because it opens the file with "a writeStream". Technically, this registers an open file handle at the OS which then inhibits destroying the file from any process, even if it's the same image that holds the open file. After closing the file associated with "aStream", the delete request should work.
      And no: #isWritable is not the full cover test which can tell in advance whether #delete will be successful. The method comment says

      isWritable
      "Answer true if file is writable by this user.
      Writable for a directory means that new files can be created or old ones renamed."

      There is a more through test called #canBeWritten, but again, it cannot foresee whether the file is still in use by this or another process.

      hope that helps
      Holger

      Am 12.05.2011 12:53, schrieb Gruenewald, Tom:

      Hello forum.
      Is #isWritable not the appropriate test method to check if a file can be deleted?
      I get an error sharing violation.
      | file a b aStream |
      file := 'c:\foo.txt'.
      a := file asFilename.
      aStream := a writeStream.

      [b := file asFilename.
      (b exists and: [b isWritable])
      ifTrue:
      ["ERROR_SHARING_VIOLATION (IO Error 32)"
      b delete]]
      ensure:
      [aStream close.
      a delete]


      Thank you for you answers.

      Best regards,
      Tom Grünewald

      ________

      Carl Zeiss Industrielle Messtechnik GmbH
      Softwareentwicklung/Software Development

      T o m G r ü n e w a l d

      73446 Oberkochen, Germany
      tel: +49.7364.20-8541
      fax: +49.7364.20-4800
      email:
      [hidden email]
      http://www.zeiss.de/imt

      Carl Zeiss Industrielle Messtechnik GmbH
      Carl–Zeiss–Straße 22, 73447 Oberkochen
      Aufsichtsratsvorsitzender: Dr. Hermann Gerlinger
      Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Axel Jaeger
      Sitz der Gesellschaft: 73446 Oberkochen, Deutschland
      Handelsregister: Amtsgericht Ulm, HRB 501561
      USt–IdNr.: DE 811 515 346


      ----------------------------------------
      This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.





      _______________________________________________
      vwnc mailing list

      [hidden email]
      http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



      ----------------------------------------
      This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




    ----------------------------------------
    This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.




----------------------------------------
This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


pic04816.gif (1K) Download Attachment