Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Opening files and file path problem.

Author
Message
SxyGuy
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location:
Posted: 11th Jan 2006 22:27
I've tried opening a file in

"C:\Program Files\Winged Fighters\Data\TestStr.wfd"

But, the DarkSDK program or function won't be able to open it. The DarkSDK function I used is:

dbOpenToWrite (
1, "C:\\Program Files\\Winged Fighters\\Data\\TestStr.wfd" );

It won't be able to open the "TestStr.wfd" file if the path is like that. I'm thinking that it isn't able to open the file because of the spaces in "Program Files" and in "Winged Fighters". So, is that the problem? If so, how can I fix it. If not, what's the problem?
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 11th Jan 2006 23:23
Why not use fopen instead ?

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 12th Jan 2006 08:20 Edited at: 12th Jan 2006 14:29
Hmmm, when I load images etc, I have to use slash instead of backslashes.
dbLoadImage( ID, "X://Dir1//Dir2//file.ext");

Please tell me if I am wrong


Alternatively to "fopen", you can use the std filestreams.

Article: http://www.cplusplus.com/doc/tutorial/files.html


//Edit dab: dec/12/2006 9.00am GMT+1
//-expand code sample

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 12th Jan 2006 14:51 Edited at: 12th Jan 2006 14:51
Quote: "Please tell me if I am wrong"

Its probably optional - I always use backslashes, but forward ones also seem to work.

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 12th Jan 2006 15:51
Great, thanks ... ehr... Stinky

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 14th Jan 2006 01:02 Edited at: 14th Jan 2006 01:08
Heh...
I've just implemented the win32api commondialog for open files and...
Actually, I could open (dbLoadObject) files with the filename/path returned by the commondialog.

So I can load (at least objects) with a filename like "SxyGuy" posted.
(with directorys seperated by single-backslash and also including spaces in directory-names: "X:\Dir 1\Dir2\file.x")


(Maybe this came in the 1.1 update or I was just "blinded"
by the samples/tutorials I've read

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 14th Jan 2006 01:15
The string at the bottom is exactly the string I use with "dbLoadObject":
(The model is freely available and licensefree)



//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 18th Jan 2006 12:18
Allright, it seems you can use SINGLE slashes/backslashes when providing a FULL path.
When using RELATIVE path, you have to use DOUBLE slashes/backslashes.

FULL path:
"X:\Dir 1\Dir2\file.ext"

RELATIVE path:
"\\Dir 1\\Dir2\\file.ext"

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 18th Jan 2006 12:42
Dont forget in C, a single \ treats the next character as an escape code - so, for a single one, you need two, eg :

"C:\\TEST\\FILE.INF"

If you did "C:\TEST\FILE.INF", it would treat \T as an escape code as well as \F

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 18th Jan 2006 13:13
Hmm, right, as I pass the string to the db-function as an sz, this will avoid file from loading if an escape code was detected.

It seems like I was just lucky enough to have selected only files that don't create an escape code...

So its better to write a converter function that will replace the "\" with "\\"... hmm... sure a thing for the DarkGame code-snippets section...

//Awards: Best DM at NeverwinterConventionIII (NWCon3)
//Sys: Pentium IV 3200E/Prescott;800Mhz FSB;HT;WinXPPro;ATIR9700PRO;1024MB RAM(2x512MB"DualChanneled";VC++7.net;Delphi6;ADSL512;
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 18th Jan 2006 14:04
It will only be a problem with literal and constant strings - values passed from APIs, for example will be okay.

Blog:http://spaces.msn.com/members/BouncyBrick/
Web Site:http://www.nicholaskingsley.co.uk
Smoke me a computer chip, I'll be baking breakfast.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jan 2006 19:19
In C & C++ the backslash is interpreted as 'the next character means something different from normal', but only within literal strings or literal characters within your C or C++ source code. That allows you to include newlines or tabs in strings for instance (\n and \t). To actually get a backslash you have to have two of them.

For free Plug-ins and source code http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-05-17 09:45:11
Your offset time is: 2024-05-17 09:45:11