Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 26, 2006 _chdir | ||||
---|---|---|---|---|
| ||||
L:\itc\exe\itc.EXE built Lines Processed: 190385 Errors: 0 Warnings: 0 Successful build the code: (in itc.cpp) int $(zero); int rootDrive(0x0002); if(!_chdrive(rootDrive))$ = getcurdir(rootDrive,buf_pointer); Returns $ == is the drive is successfully changed.... From the help files: The _chdir function changes the current directory to the one specified in the path argument. dm\html\rtl\direct.html says the same thing. in: L:\itc\methods.h static char const * const win_path = {"\\WINDOWS"}; also tried: static char const * const win_path = {"WINDOWS"}; sc itc.cpp -cpp -HO -p -mn -WA -S -5 -a8 -Nc -c -e -gf #include "methods.h" line: 101 $ = ::chdir(const_cast<char*>(win_path)); returns -1 ::perror(" Failed chdir : \r\n"); returns: No such file or directory The way this 'drive and directory' concept is works is sub-optimal and I welcome suggestions for 'trial by fire' testing and probing. What does ':' signifiy ? Should it be in the string passed to chdir ? |
March 18, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Jordan | It will really help if you isolate this down into a minimal file. |
April 16, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <dvgiua$1lma$1@digitaldaemon.com>, Walter Bright says... > >It will really help if you isolate this down into a minimal file. > > To narrow down my original question: "failed _chdir" ...if you specify a drive in the path argument, the current directory on that drive is changed. However,Test stubb produces: failed _chdir on C:\\WINDOWS C:\WINDOWS Test stubb follows: /*=======================================*/ static char const * const win_path_1 = {"WINDOWS"}; static char const * const win_path_2 = {"\\WINDOWS"}; static char const * const win_path_3 = {"C:\\WINDOWS"}; register $(0x0000); int rootDrive(0x0002); FILE* fp_2 = ::fopen("B:\\runlog.log","wb"); $ = _chdrive(rootDrive); ::strcpy(buf_pointer,win_path_1); if(!::_chdir(buf_pointer))\ ::fprintf(fp_2,"failed _chdir on WINDOWS %s ",buf_pointer); ::strcpy(buf_pointer,win_path_2); if(!::_chdir(buf_pointer))\ ::fprintf(fp_2,"failed _chdir on \\\\WINDOWS %s ",buf_pointer); ::strcpy(buf_pointer,win_path_3); if(!::_chdir(buf_pointer))\ ::fprintf(fp_2,"failed _chdir on C:\\\\WINDOWS %s ",buf_pointer); ::fclose(fp_2); /*=======================================*/ //eof |
April 16, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Jordan | _chdir should work like the cd command in a console window. It doesn't change the drive, that is done with a separate command. |
April 22, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <e1u0jv$en$1@digitaldaemon.com>, Walter Bright says... > >_chdir should work like the cd command in a console window. It doesn't change the drive, that is done with a separate command. The original post accounted for that - int $(zero); int rootDrive(0x0002); if(!_chdrive(rootDrive))$ = getcurdir(rootDrive,buf_pointer); I ran this about five times, reading the help files to confirm before posting... The if(!_chdrive(rootDrive)) was supposed to execute the _chdrive func, and the not operator cause the getcurdir() to occur. All optimizations were turned off, and debug was selected in the IDE to get the order of eval to behave as a beginner would like it to. Not to be difficult, "change the drive" v. "the default drive" What I was originally trying to determine - from someone who knew what they were talking about: "Least-Risk method of fwrite's and fread's on deeply buried control files, presenting to the routine user more commonly understandable paths's and iconics so as to provide recovery and detection avenues programmatically." The help files (direct.html#_chdir) state: " ...if you specify a drive in the path argument, the current directory on that drive is changed." The above code was supposed to account for the possibility that one would have to _chdrive first before _chdir() would work correctly. But, second round of testing (Posted: Sun, 16 Apr 2006 16:45:37 +0000 (UTC)) reveals: "failed _chdir on C:\WINDOWS" Freshly posted from testing with adreneline pumping and shame motivating to insure I had preened to isolate the barest possible test harness, I note direct.html#_chdir does not state -1 is returned if you specify a drive in the path argument. Nick |
April 22, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Jordan | Did you try the example programs from the documentation? |
April 29, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <e2dq54$2d0k$1@digitaldaemon.com>, Walter Bright says... > >Did you try the example programs from the documentation? ? I always read the sample code, the header file and any book I can get on each subject, tool or style. Sample code does not mention anything about what the user can type in - and they won't be typing in directories in my finished work anyway. Proven Blunder Bus. And it's sample program, not samples, unless I missed something. /*===== http://www.digitalmars.com/rtl/direct.htm 4-29-2006 =====*/ void main() { char changeto[64]; int result; printf ("Enter directory to change to :"); scanf ("%s", changeto); result = _chdir(changeto); if (result != 0) perror ("ERROR changing directory"); else printf ("Current directory now :%s\n", changeto); } Description states: For example, if you specify a drive in the path argument, So what do we mean by 'you' ? - c/cpp code or user of the program. |
May 13, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Jordan | Nicholas Jordan wrote: > In article <e2dq54$2d0k$1@digitaldaemon.com>, Walter Bright says... >> Did you try the example programs from the documentation? > > ? It seems to work fine if I try it: --------------------------------- C:\cbx\ztc>type test.cpp #include <stdio.h> #include <direct.h> void main() { char changeto[64]; int result; printf ("Enter directory to change to :"); scanf ("%s", changeto); result = _chdir(changeto); if (result != 0) perror ("ERROR changing directory"); else printf ("Current directory now :%s\n", changeto); printf("cwd = '%s'\n", getcwd(changeto, 64)); } C:\cbx\ztc>sc test link test,,,user32+kernel32/noi; C:\cbx\ztc>test Enter directory to change to :\cbx Current directory now :\cbx cwd = 'C:\cbx' C:\cbx\ztc> ------------------------------------------ |
June 25, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <e45oi2$2oju$1@digitaldaemon.com>, Walter Bright says... > >Nicholas Jordan wrote: >> In article <e2dq54$2d0k$1@digitaldaemon.com>, Walter Bright says... >>> Did you try the example programs from the documentation? >> >> ? > >It seems to work fine if I try it: >--------------------------------- In other words: "For example, if you specify a drive in the path argument, the current directory on that drive is changed." Should be removed from the help files. dmc - Version 8.42n Your code follows that of the example - essentially is the example - but what I did follows the directions (above) from the .hlp files. Started making some real progress this morning on statistical traffic analysis, would really like to get resolution on this over the next week or two. Nick - aka 'Crazy Guy in Texas' //eof |
June 26, 2006 Re: _chdir | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nicholas Jordan | Nicholas Jordan wrote:
> In article <e45oi2$2oju$1@digitaldaemon.com>, Walter Bright says...
>> Nicholas Jordan wrote:
>>> In article <e2dq54$2d0k$1@digitaldaemon.com>, Walter Bright says...
>>>> Did you try the example programs from the documentation?
>>> ?
>> It seems to work fine if I try it:
>> ---------------------------------
>
> In other words:
>
> "For example, if you specify a drive in the path argument, the current directory
> on that drive is changed."
>
> Should be removed from the help files.
>
> dmc - Version 8.42n
>
> Your code follows that of the example - essentially is the example - but what I
> did follows the directions (above) from the .hlp files.
>
> Started making some real progress this morning on statistical traffic analysis,
> would really like to get resolution on this over the next week or two.
I don't understand what resolution you need. The function works - it only changes the directory, not the drive.
|
Copyright © 1999-2021 by the D Language Foundation