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.

DarkBASIC Professional Discussion / Copying the entire folder

Author
Message
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 28th Jul 2014 17:05
Hello community

Does anyone know, how can copy an entire folder with all it's contents?

Thank You!

Rims Flames
Hotline
16
Years of Service
User Offline
Joined: 22nd Aug 2008
Location:
Posted: 28th Jul 2014 20:24 Edited at: 28th Jul 2014 20:25
1 Create a folder with a same name as the original
2 Iterate through the original folder's files an copy them in the new folder

[href=forum.thegamecreators.com/?m=forum_view&t=191567&b=5]Spark Particle engine[/href]
[href=forum.thegamecreators.com/?m=forum_view&t=199163&b=5]Transform gizmo plugin[/href]
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 28th Jul 2014 20:57
Well, if a user wants to put their custom files in that folder how am i supposed to know what file it is?

Rims Flames
SamKM
15
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 28th Jul 2014 22:23
You should be able to use the 'find first' and 'find next' commands to check each file in a directory, and then use 'get file name/date/type' commands to retrieve file information

The code never bothered me anyway...
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 28th Jul 2014 22:31
So, i am making an editor and i have a package method that gets all the folders...but the files can copy them only if i personally created. But from other user not. I understand what you said SamKM, i tried to re explain, can you please provide me with an example? I really appreciate it!

Rims Flames
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 30th Jul 2014 12:37
Anyone with an example if you want please?

Thank You!

Sorry for the bump...

Rims Flames
Hotline
16
Years of Service
User Offline
Joined: 22nd Aug 2008
Location:
Posted: 30th Jul 2014 17:11
Well to solve your problem is so trivial that i don't think anyone will take time to write you an example...
Press F1 in the editor , navigate to "File commands" and i'm sure you will be able to figure it out in 15 - 20 minutes.

HINT :
Create a file that will contain the name of all files which are created by YOU and CAN be copied.
loop through the files in the folder.If you find a file that is on your list , copy it if not on the list , don't copy...

Cheers

[href=forum.thegamecreators.com/?m=forum_view&t=191567&b=5]Spark Particle engine[/href]
[href=forum.thegamecreators.com/?m=forum_view&t=199163&b=5]Transform gizmo plugin[/href]
Rudolpho
19
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 31st Jul 2014 13:38
I think the main "problem" with this is copying sub-folders as well.
An easy solution to that is to use a recursive function, that is one that copies all files in a folder and then calls itself for all directories until the only two directories that exist in the current folder are the special "." and ".." ones (which mean "this folder" and "upper level folder" respectively).


"Why do programmers get Halloween and Christmas mixed up?"
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 31st Jul 2014 20:19
I understand...thank you for your response!

Rims Flames

Login to post a reply

Server time is: 2025-05-13 18:28:30
Your offset time is: 2025-05-13 18:28:30