Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 24-Apr-2008 18:35
User is offline View Users Profile Print this message


jason haury

Posts: 39
Joined: 20-Feb-2007

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
Report this to a Moderator Report this to a Moderator
 24-Apr-2008 21:38
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 13-May-2008 19:21
User is offline View Users Profile Print this message


Chris Jones

Posts: 177
Joined: 1-Jul-2005

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.