Author Topic: [Request] Create/Delete/Management of Directories & Files  (Read 1242 times)

0 Members and 1 Guest are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
[Request] Create/Delete/Management of Directories & Files
« on: August 31, 2009, 03:24:37 pm »
Basically, ability to create and delete folders
[create], delete files
retrieve file size off of a file
I would guess this would have to be done using shell_exec, and since I have hardly any experience with shell on either windows nor linux, here is a request for anybody who bored.

procedure (Create|Delete)(File|Folder)(const Filename: string); // or maybe return a boolean for success or not, or throw an exception if failure
function Filesize(const Filename: string): cardinal?;
(aka 5 different procedures/functions)

I'm also curious if it is possible to append text at the end of a file using shell, as that would be useful as well.

Windows higher priority than linux in this case, but preferred to work under both. (may need a check, there a built in variable containing the OS)

EDIT: I just remembered that shell_exec's return value is an integer.. I'm not certain about what it can be used for, but in regards to filesize and stuff, if worst comes to worst, create a temporary file and put it there, set the result to the contents of that file, and then delete the file.

EDIT2: As mentioned in IRC, other useful things: procedure Rename(const FileDir: string); procedure Copy(const File1, File2: string);

EDIT3: I found out what the prefix should be to fix the 8-letter all caps issue - prefix everything with "cmd /c " (excluding the quotes), thanks to Shoozza many months ago.
« Last Edit: October 10, 2009, 09:28:19 am by DorkeyDear »

Offline Gizd

  • Flagrunner
  • ****
  • Posts: 586
  • (Re)tired
    • Eat-this! community site
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #1 on: August 31, 2009, 04:13:15 pm »
Windows cmds: http://ss64.com/nt/

md <name>  - create folder
rd <folder>  - delete folder (folder must be empty!)
copy <file/folder> <direction(ie C:\blah\)>  - copy file or all files in folder
del <file/folder>  - delete file or all files in folder
ren <file/folder> <new_name>  - renames file/folder
« Last Edit: August 31, 2009, 04:36:18 pm by Gizd »

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #2 on: August 31, 2009, 04:50:15 pm »
Would be quite simple as I see it now... I should do a test script.

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #3 on: August 31, 2009, 05:20:25 pm »
There should also be a procedure to change a file's permissions, and the procedures should perform a check that they aren't being used to do anything malicious, such as altering the soldat server binaries or other files the user account running the server has access to.
There are other worlds than these

Offline ~Niko~

  • Rainbow Warrior
  • *****
  • Posts: 2410
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #4 on: August 31, 2009, 06:13:00 pm »
I'm interested on this, maybe I do something like this :)

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #5 on: August 31, 2009, 07:51:41 pm »
Note that there is some way (I forget what it is and whomever told me how) to fix the 8-letter character limit thingy. I may or may not have it laying around somewhere. I quickly looked and didn't see it though.

Offline LORD KILLA

  • Camper
  • ***
  • Posts: 254
  • Happie
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #6 on: October 10, 2009, 04:03:58 am »
There should also be a procedure to change a file's permissions, and the procedures should perform a check that they aren't being used to do anything malicious, such as altering the soldat server binaries or other files the user account running the server has access to.

Linux: chmod xxx

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #7 on: October 10, 2009, 04:49:18 am »
There should also be a procedure to change a file's permissions, and the procedures should perform a check that they aren't being used to do anything malicious, such as altering the soldat server binaries or other files the user account running the server has access to.

Linux: chmod xxx

Yes...but I was talking about a function in the scriptcore for it, not having to call it manually using shell_exec();

And don't reply to a nearly dead topic with a next-to-worthless message again.
There are other worlds than these

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: [Request] Create/Delete/Management of Directories & Files
« Reply #8 on: October 10, 2009, 08:57:29 am »
There should also be a procedure to change a file's permissions, and the procedures should perform a check that they aren't being used to do anything malicious, such as altering the soldat server binaries or other files the user account running the server has access to.

Linux: chmod xxx

Yes...but I was talking about a function in the scriptcore for it, not having to call it manually using shell_exec();

And don't reply to a nearly dead topic with a next-to-worthless message again.

But it was of use for me though :(

Besides - that post reminded me of this. ima give an attempt at these functions for at least windows (as it seems nobody wants to make it themselves :D), and I'll edit this topic once I get soemthing (if I remember :P)