Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (TipmyPip, OptimusPrime, AndrewAMD), 14,882 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to create a folder #344583
10/18/10 16:09
10/18/10 16:09
Joined: Nov 2003
Posts: 433
The Netherlands
T
Toon Offline OP
Senior Member
Toon  Offline OP
Senior Member
T

Joined: Nov 2003
Posts: 433
The Netherlands
Hi,

I want to save my game settings to C:\Users\[username]\appdata\Roaming\[gamename]\ in Vista and the similar folder for other operating systems...

I use the dll plugin from the wiki to get the path of this directory but what is the best way to create a folder there, I checked the manual but i could not find anything

Does someone know how to do this...with file_open_write it only writes a file and doesnt create the folder if it doesnt excist...

Re: How to create a folder [Re: Toon] #344718
10/20/10 00:07
10/20/10 00:07
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Try my example below. Maybe it helps.

Code:
#include <default.c>
#include <stdio.h>
#include <windows.h>

FONT* A20 = "Arial#20";
char* cNewDirFolderName;
STRING* sFolderName = "New Folder";
STRING* sWorkDir = "";

PANEL* pInfo = {
    digits(5,10,"[C] - Folder Create", A20, 0, 0);
    digits(5,30,"[D] - Folder Delete", A20, 0, 0);
    digits(5,50,"Work Folder: %s", A20, 0, sWorkDir);
    digits(5,70,"New Folder Name: %s", A20, 0, sFolderName);
    flags = SHOW;
}

function fPutGameFolder(STRING* WorkDir, STRING* FolderName) {
    str_cpy(sWorkDir, work_dir);
    str_cat(WorkDir, FolderName);
    static char szFile[256];
    ZeroMemory(szFile,256);
    int Size = str_len(WorkDir);
    strcpy(szFile,_chr(WorkDir));
    strcpy(szFile+Size+1,_chr(WorkDir));
    cNewDirFolderName = szFile;
    return (cNewDirFolderName);
}

function on_d_event() {
    while (key_d){wait(1);}
    fPutGameFolder(sWorkDir, sFolderName);
    _rmdir(cNewDirFolderName); // The directory folder to be deleted.
    str_cpy(sWorkDir, work_dir);
}

function on_c_event() {
    while (key_c){wait(1);}
    fPutGameFolder(sWorkDir, sFolderName);
    _mkdir(cNewDirFolderName); // The directory folder to be created.
}

function main() {
    str_cpy(sWorkDir, work_dir);
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: How to create a folder [Re: rojart] #345142
10/23/10 15:37
10/23/10 15:37
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Thanks for the sample... but I wonder if this can't be done easier by jcl.
It's an annoying missing feature.

Re: How to create a folder [Re: FBL] #345157
10/23/10 17:13
10/23/10 17:13
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Code:
#include <acknex.h>
#include <windows.h>

typedef struct _SECURITY_ATTRIBUTES {
  DWORD  nLength;
  void* lpSecurityDescriptor;
  BOOL   bInheritHandle;
} SECURITY_ATTRIBUTES;

int create_folder(STRING* path){
	SECURITY_ATTRIBUTES quad_DirAttribs;
	quad_DirAttribs.nLength = sizeof(SECURITY_ATTRIBUTES);
	quad_DirAttribs.lpSecurityDescriptor = NULL;
	quad_DirAttribs.bInheritHandle = TRUE;
	return CreateDirectory(_chr(path),&quad_DirAttribs);
}



void main(){
	create_folder("c:\\TestDir");
}


returns non-zero if it succeeds.


you probably want to add that struct to your windows.h

Last edited by Quadraxas; 10/23/10 17:14.

3333333333
Re: How to create a folder [Re: Quad] #345244
10/24/10 13:36
10/24/10 13:36
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
This is also one of the easiest ways to work, but without lpSecurityAttributes, like Quadraxas sample.

Quote:
If lpSecurityAttributes is NULL, the directory gets a default security descriptor. The ACLs in the default security descriptor for a directory are inherited from its parent directory.


Code:
#include <acknex.h>
#include <windows.h>

function main() {CreateDirectory(_chr(str_cat(work_dir,"My_New_Folder")),NULL);}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1