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 / Problem with renaming files

Author
Message
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 22nd Jun 2006 08:04 Edited at: 22nd Jun 2006 08:07
Ok, for some reason, my file isnt being renamed.
I am doing this to prevent the casual user from lifting media.

Here is the sound code:


Attached is a demo of the problem.

You will see that menu.xsf remains tempxsf.wav in the folder.

Escape key to exit after 2 screens have completed.

Attachments

Login to view attachments
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 23rd Jun 2006 06:43
b-u-m-p
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 23rd Jun 2006 11:28
Have you tried the standard C function - to see whether its a SDK problem ?

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Dont do anything I wouldn't do. But if you do, take pictures.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 23rd Jun 2006 18:40
No I have not.

It works fine for all of my images though, the exact same code, except for the different rename.

Current Project: CTA Beta
Lines: 559
Last Updated: 6/23/06 at 12:23 AM EST.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 23rd Jun 2006 18:44 Edited at: 23rd Jun 2006 18:45
The only reasons it can fail are :

A) Source not present (or invalid)
B) Destination already exists (or invalid)
C) Bug in the SDK

Use a standard C rename function to check out C, and then it'll just be a matter of checking A and B

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Dont do anything I wouldn't do. But if you do, take pictures.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 23rd Jun 2006 18:53
Ok Ill do that.

For now, here is the xiemsfiles header



And where I set the value for sMenuMusic



Where I make the LoadSound call



Current Project: CTA Beta
Lines: 559
Last Updated: 6/23/06 at 12:23 AM EST.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 23rd Jun 2006 19:00 Edited at: 23rd Jun 2006 19:02
rename(sTempFile,sFileName); returns the same problem.
Its not being renamed back to what it was

I am able to rename it back to an XSF just fine with a file rename app I made for doing this. That works just fine.

Current Project: CTA Beta
Lines: 559
Last Updated: 6/23/06 at 12:23 AM EST.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jun 2006 20:43
Using the standard rename function, what value do you get in the errno variable? (You may need to include errno.h to get access to this variable)

For free Plug-ins and source code http://www.matrix1.demon.co.uk
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 23rd Jun 2006 20:54
I have never used errno.

The rename function does return the value of -1 though.

Current Project: CTA Beta
Lines: 629
Last Updated: 6/23/06 at 1:06 PM EST.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jun 2006 23:38
That doesn't really help us to help you.

Include errno.h, rename the file, then tell us what the errno variable contains.

From the VS help for rename:
Quote: "Return Value
Each of these functions returns 0 if it is successful. On an error, the function returns a nonzero value and sets errno to one of the following values: ..."


If you tell us what value the errno global variable contains when rename fails, we can work out what's going on.

For free Plug-ins and source code http://www.matrix1.demon.co.uk
Kaiyodo
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 24th Jun 2006 00:36
When dbLoadSound() opens a file it doesn't close it until you call dbDeleteSound() or quit your app. Because the file is open you won't be able to delete or rename it while you have it loaded.

For a test, load the sound then try and rename the file from Windows Explorer while your app is running. You should get an error message like "Cannot Rename blah.wav. It is being used by another person or program".

Kaiyodo.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 24th Jun 2006 05:16 Edited at: 24th Jun 2006 05:37
Oh, so this should go away assuming that I close the file before renaming?

Will that be the case for mesh files too?

How do I change the last 3 letters of a string?
Can I do something like getting the length of the string, and then doing something like

ix= len(char)
variable[ix-2] = 'x'
variable[ix-2] = 's'
variable[ix] = 'f'


[EDIT] That creates and access violation.



Current Project: CTA Beta
Lines: 629
Last Updated: 6/23/06 at 1:06 PM EST.
Kaiyodo
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 24th Jun 2006 15:31 Edited at: 24th Jun 2006 15:31
Yes, your renaming problem should go away if you close the file before renaming it. The only way you'll be able to do that is to call dbDeleteSound though, and that's not going to help you if you still want to use the sound.

I don't think the same problem exists with meshes or images, in fact there's no reason I can think of why it should need to be the case for sounds. The only reason you'd need to keep a sound file open would be if you were streaming it from the disk and as that's unlikely for sound effects, it sounds more like a bug.

There are two reasons why your code for changing the last three letters of a string won't work. The obvious one is that your array indices are off. The length of "FileName.ext" will return 12, however indexing element 12 of a zero based array will access outside the array. In the particular case of a string, that character would be the zero terminator so you'll end up with a string like "FileName.ewavÌÌÌÌÌ". Subtracting 1 from the return value of dbLen() will fix that.

The second reason it won't work is because I can see from your earlier code that you're assigning your string pointers using code like this ..



Due to the way the compiler handles string literals, they end up in an area of read-only memory so assigning them to a pointer and trying to modify them directly will cause an access violation. To get the string into an editable area of memory you'll need to copy it rather than just take a pointer. Use something like this instead ..



Kaiyodo.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 24th Jun 2006 15:42
I think WAVs are buffered, so the file needs to be kept open.

Come to the last Unofficial DBPro Convention (http://convention.logicstudios.net/)
Dont do anything I wouldn't do. But if you do, take pictures.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 24th Jun 2006 18:56 Edited at: 24th Jun 2006 19:03
Thanks, Ill get onto the new code, and see how it goes

[EDIT]

New Code Example:


Results in:



Current Project: CTA Beta
Lines: 629
Last Updated: 6/23/06 at 1:06 PM EST.
Kaiyodo
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: UK
Posted: 24th Jun 2006 19:24
This ..

Needs to be this ...


And by the looks of it you are trying to rename your file before you call dbDeleteSound(), so your rename will still fail because the file is open.

Kaiyodo.
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 24th Jun 2006 19:49 Edited at: 24th Jun 2006 19:52
Ah yes, changed that
There is only one problem I can find now.

The program crashing, if it crashes before I rename, then its all messed up

I suppose I could write a function that checks to make sure the files have been renamed upon restarting the program.

Current Project: CTA Beta
Lines: 629
Last Updated: 6/23/06 at 1:06 PM EST.

Login to post a reply

Server time is: 2024-05-18 22:20:37
Your offset time is: 2024-05-18 22:20:37