![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Checking file write permissions w/o erasing file Topic Summary: Checking existence of then appending to a log file without erasing it Created On: 24-Apr-2008 18:35 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I'm trying to write some code that will first test to see if it can write to a file path before creating a stream (setting a stream using append() will error out if the path is not writable). DOORS has CanOpenFile(string, bool) which will test writablilty if bool is set to True. However, it also erases the file contents! How can I check file permissions for the current user (perhaps using Stats?) without disturbing file contents?
My solution at the moment is to read the file first, and then use CanOpenFile(). If it can open for write, then I'll first restore the file by writing back to the file what was just deleted. This seems to be a poor use of clock cycles though. Any tips? Jason |
|
![]() |
|
![]() |
|
You can surround your append with the standard error trapping routines noError and lastError, something like attached.
Lots of commands need to be trap-protected like this, for example perhaps the close(st) command. - Louie |
|
![]() |
|
![]() |
|
Even better than that, see $DOORSHOME/lib/dxl/utils/fileops.dxl for some pre-written file checking functions.
If you have the Kitchen scripts (search the forums if not), they added a couple other functions too (fileops.inc). Chris |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.