|
Rockbox mail archiveSubject: Re: need a function to delete an (empty) directoryRe: need a function to delete an (empty) directory
From: [IDC]Dragon <idc-dragon_at_gmx.de>
Date: Fri, 9 Apr 2004 12:49:41 +0200 (MEST) > Does somebody have a rmdir function "in the drawer", or have I overlooked > a possible way? > I don't feel like messing around in that part of the code, would welcome > some help. I had a deeper look, to my best understanding I've written the function below, from tidbits of the directory and file delete code. (What does fat_truncate do?) But it doesn't seem to have an effect at all, the directory stays. The file and FAT code is very sparsely commented, hence the cc to the authors. ;) Sorry for bothering, Jörg int rmdir(char* name) { int rc; DIR* dir; struct dirent* entry; dir = opendir(name); if (!dir) { errno = ENOENT; /* open error */ return -1; } /* check if the directory is empty */ while ((entry = readdir(dir))) { if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) { DEBUGF("rmdir error: not empty\n"); errno = ENOTEMPTY; closedir(dir); return -1; } } rc = fat_truncate(&(dir->fatdir.file)); if ( rc < 0 ) { DEBUGF("Failed truncating dir: %d\n", rc); errno = EIO; rc = -1; } rc = fat_remove(&(dir->fatdir.file)); if ( rc < 0 ) { DEBUGF("Failed removing dir: %d\n", rc); errno = EIO; rc = -1; } closedir(dir); return rc; } -- NEU : GMX Internet.FreeDSL Ab sofort DSL-Tarif ohne Grundgebühr: http://www.gmx.net/info _______________________________________________ http://cool.haxx.se/mailman/listinfo/rockboxReceived on 2004-04-09 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |