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: changing directories programmatically
Topic Summary:
Created On: 29-Sep-2008 06:53
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.
 29-Sep-2008 06:53
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

I'm using the mkdir() to create a folder under my C:\myown\xyz folder. I want to create folders and sub-folders under the xyz folder, through a script. Using mkdir(), I'm able to create a folder under xyz; however, I'm not sure how to create a folder under the folder I just created. Meaning, is there an equivalent of "cd" command (in windows) so that I can drive down to the folder and then use mkdir()?

Thanks.
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 14:37
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Why make life hard.
Following command will make all subdirectories:


system "cmd /c mkdir c:\\temp\\a\\b\\c"
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 15:11
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

Thanks Ron. Similarly, how do we check if a directory already exists? Can we used ckdir() with the system call?

Thanks

Edited: 29-Sep-2008 at 17:49 by anant mitra
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 15:22
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Folloing function works for files or directories

bool fileExists_(string filename)
{ Stat sT
sT = create filename
if (null sT) return false
delete sT
return true
}

print fileExists_("c:\\temp\\b") ""
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 15:25
User is offline View Users Profile Print this message


Tony Goodman

Posts: 97
Joined: 6-May-2008

An alternative method is to use my mkdir function which creates the entire path and traps errors returned by the mkdir system call.

http://www.smartdxl.com/filesdirs.html

-------------------------
Tony Goodman
Smart DXL limited
www.smartdxl.com
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 18:36
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

I tried, mkdir, create and the method given by Ron. None of them have been able to do what I want. So, I'm posting my script just to make sure I got the code right.

It helps have another set of eyes look at it.
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 19:47
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

The doors mkDir requires you to create each folder with a command.

The system requires you to conver doors / to \\ to work.

You best approache is:
--look at Tonies makeDir include file
or
-- convert / to \\ in your string path_name
or
--or parse the path and make one directory at a time with the mkdir function.
Report this to a Moderator Report this to a Moderator
 29-Sep-2008 20:27
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

Thanks Tony. I used your makeDir() and although got a stack overflow error, I used Edwin's fix for it and it worked.

Just a little nitpick - It's created the folders under the C:. How do I create the folders under C:\My Documents? I tried prefixing my path_name with C:\My Documents, but that didn't help

Thanks much!

Edited: 29-Sep-2008 at 20:36 by anant mitra
Report this to a Moderator Report this to a Moderator
 30-Sep-2008 08:34
User is offline View Users Profile Print this message


Paul Howstan

Posts: 47
Joined: 27-Sep-2006

My documents is actually in a folder as follows:

C:\Documents and Settings\username\My Documents

Paul
Report this to a Moderator Report this to a Moderator
 30-Sep-2008 12:32
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Your problems isn't a nit with Tonies script, Because of the spaces you may have to either use quotation marks or a space character subsitution and of course you must have the correct name.

Edited: 30-Sep-2008 at 14:11 by ron lewis
Report this to a Moderator Report this to a Moderator
 30-Sep-2008 18:57
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

The variable path_name that I'm using contains, for example, /x/y. I'm prefixing it with C:\My Documents like this: path_name = "C:\\My Documents" path_name. I've tried path_name = "C:/My Documents" path_name as well. But, it still creates it under C:\.

How do I fix this?
Report this to a Moderator Report this to a Moderator
 30-Sep-2008 19:20
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

When I type "c:\My Documents" into Windows Explorer, I get an Error. I don't think that is a valid path, instead I think its just an alias to "c:\Documents and Settings\UserName\My Documents".

- Louie
Report this to a Moderator Report this to a Moderator
 30-Sep-2008 20:47
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

You are right. It's not a valid path. I tried another path and it worked.

Thanks All.
Report this to a Moderator Report this to a Moderator
 23-Oct-2008 22:30
User is offline View Users Profile Print this message


anant mitra

Posts: 50
Joined: 27-Jul-2007

Hello,

My script runs as a scheduled task every night. It should delete the existing directory ('XYZ' given in the code) and create it all over again. However, it's not happening. What's the problem here?

Thanks.
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.