|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Ok, I've only got one last thing to add to this silly GUI Extension, and I
just can't figure out how to do it. It's a simple simple thing to do, I
just haven't worked in C/C++ so long, and I don't have any C++ books
anymore.
From the command-line the user passes in a file let's say "scene.pov". Now,
POV wants the GUI Extension to pass the full path name of the file, let's
say, "c:\povfiles\scene.pov".
Here are my questions. How can I tell if a file exists? How can I get the
"current working directory" in a C program? in a C++ program? How can I
tell if a file path is absolute? This will only ever run on Windows, so
Windows API calls are ok too...
Thanks!
--
#macro Q(A,E,W)box{-A/2,A/2pigment{rgb 9*W}translate E*A+W/1000}#end#macro
M(D,E)#local A=1/pow(3,D);#if(D<3)#local C=D+1;union{M(C,1)M(C,x+y)M(C,x+z)
M(C,y+z)M(C,x+y-z)M(C,x+z-y)M(C,y+z-x)M(C,x-y)M(C,z-x)M(C,y-z)M(C,y-x)M(C,
x-z)M(C,z-y)M(C,x-y-z)M(C,y-x-z)M(C,z-x-y)translate A*E}#else Q(A,E,x)Q(A,E
,y)Q(A,E,z)#end#end union{M(0,0)rotate<45,145,0>translate z*2}//Andrew
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Andrew Wilcox" <awi### [at] unpuzzledcom> wrote in
news:3d9e1321@news.povray.org:
> Ok, I've only got one last thing to add to this silly GUI Extension, and
> I just can't figure out how to do it. It's a simple simple thing to do,
> I just haven't worked in C/C++ so long, and I don't have any C++ books
> anymore.
>
> From the command-line the user passes in a file let's say "scene.pov".
> Now, POV wants the GUI Extension to pass the full path name of the file,
> let's say, "c:\povfiles\scene.pov".
>
> Here are my questions. How can I tell if a file exists?
int _access(const char *path, int mode);
mode Checks File For
00 Existence only
02 Write permission
04 Read permission
06 Read and write permission
Each of these functions returns 0 if the file has the given mode. The
the given mode; in this case, errno is set as follows:
access.
ENOENT Filename or path not found.
The Win32 API way is probably to use FindFirstFile, but it is too much just
for this...
You can also try to open it and check the result, but it is practical only
if you really need to open it.
> How can I get the "current working directory" in a C program? in a C++
> program?
char *_getcwd(char *buffer, int maxlen);
or
DWORD GetCurrentDirectory(
DWORD nBufferLength, // size of directory buffer
LPTSTR lpBuffer // directory buffer
);
No difference, as far as you do API calls, between C and C++.
Now, STL can have functions of its own.
> How can I tell if a file path is absolute? This will only ever run on
> Windows, so Windows API calls are ok too...
AFAIK, it can start with '\\' (including network paths (UNC)
\\servername\...) or "<letter>:\".
You can also use _splitpath:
char sDrive[_MAX_DRIVE + 1];
char sDir[_MAX_DIR + 1];
char sFName[_MAX_FNAME + 1];
char sExt[_MAX_EXT + 1];
_splitpath(path, sDrive, sDir, sFName, sExt);
--
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thank you!
--
#macro Q(A,E,W)box{-A/2,A/2pigment{rgb 9*W}translate E*A+W/1000}#end#macro
M(D,E)#local A=1/pow(3,D);#if(D<3)#local C=D+1;union{M(C,1)M(C,x+y)M(C,x+z)
M(C,y+z)M(C,x+y-z)M(C,x+z-y)M(C,y+z-x)M(C,x-y)M(C,z-x)M(C,y-z)M(C,y-x)M(C,
x-z)M(C,z-y)M(C,x-y-z)M(C,y-x-z)M(C,z-x-y)translate A*E}#else Q(A,E,x)Q(A,E
,y)Q(A,E,z)#end#end union{M(0,0)rotate<45,145,0>translate z*2}//Andrew
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|