Jump to content

FILE_DirExists with variable Dir


Recommended Posts


thats works:

FILE_DirExists("a");	// check for a Folder named a


get the warning: "warning: passing argument 1 of 'FILE_DirExists' makes pointer from integer without a cast [enabled by default]"

char directory = a
FILE_DirExists(directory);	// directory is a variable


is it possible to check for a Variable-Dir?

file.c says:

//! Returns 1 if directory exists, 0 if it doesn't exist, < 0 on errors
s32 FILE_DirExists(char *path)
  DIR dir;

  if( !volume_available ) {
    DEBUG_MSG("[FILE_DirExists] ERROR: volume doesn't exist!\n");
    return FILE_ERR_NO_VOLUME;

  if( !path || !path[0] )
    return 0; // empty directory name - handle like if it doesn't exist

  return (file_dfs_errno=f_opendir(&dir, path)) == FR_OK;


Link to comment
Share on other sites

i got it:

// change Folder Directory  -  letter loadet from previos loaded SYS-File
char Folder = 'a';
char path[8];
strncpy(path,  "a       ", 8);
path[0] = Folder;
statusDir 	= FILE_DirExists(path);	 		// ask file.c: exist a folder "a/" on the CARD? //


char Folder = A’;
char path[8];
// Build File Path/0.t4      "
sprintf   (path, "%c/0.b4",Folder);

// ask file.c: exist a file "A/0.b4" on the CARD? // 
statusFile_patch = FILE_FileExists(path);	

and for delete all Files - and Directory(if all files are known and already deleted

// you need to delete each file on its own...
int c; for (c=0; c<256; c++)	{
						char remove[9];
 						 // make a new filename depending on the counter value
						sprintf   (remove, "%c/%d.b4",Folder,c);

						// Remove FILEs

// Remove Directory (can only be done if it empty
	// build path
	char remove[8];

	sprintf   (remove, "%c",Folder);

whoud be interesting, how to delete a folder if the Files inside are not known?

Edited by Phatline
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...