|
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
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Try my example below. Maybe it helps.
#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);
}
|
|
|
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
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
#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
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
This is also one of the easiest ways to work, but without lpSecurityAttributes, like Quadraxas sample. 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.
#include <acknex.h>
#include <windows.h>
function main() {CreateDirectory(_chr(str_cat(work_dir,"My_New_Folder")),NULL);}
|
|
|
|