本文整理汇总了C++中read_directory函数的典型用法代码示例。如果您正苦于以下问题:C++ read_directory函数的具体用法?C++ read_directory怎么用?C++ read_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_directory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clean_temp_dirs
static void
clean_temp_dirs () {
bool err= false;
array<string> a= read_directory (main_tmp_dir, err);
#ifndef __MINGW32__
for (int i=0; i<N(a); i++)
if (is_int (a[i]))
if (!process_running (as_int (a[i])))
if (a[i] != as_string ((int) getpid ()))
system ("rm -rf", url (main_tmp_dir) * url (a[i]));
#else
/* delete the directories after 7 days */
time_t ts = as_int (basename (url_temp_dir_sub ())) - (3600 * 24 * 7 );
for (int i=0; i<N(a); i++)
if (is_int (a[i])) {
time_t td= as_int (a[i]);
if (td < ts) {
url cur = url (main_tmp_dir) * url (a[i]);
array<string> f= read_directory (cur, err);
for (int j=0; j<N(f); j++) remove (cur * url (f[j]));
_rmdir (as_charp (as_string (cur)));
}
}
#endif
}
示例2: read_directory_sx
sexpr read_directory_sx (sexpr rx)
{
sexpr r = sx_end_of_list;
if (graphp (rx)) {
r = read_directory_rx (".", rx);
} else if (stringp (rx)) {
r = read_directory (sx_string (rx));
} else if (symbolp (rx)) {
r = read_directory (sx_symbol (rx));
}
return r;
}
示例3: indir
camera_directory<Tdata>::camera_directory(const char *dir,
int height_, int width_,
bool randomize_, uint npasses_,
std::ostream &o, std::ostream &e,
const char *pattern,
const std::list<std::string> *files)
: camera<Tdata>(height_, width_, o, e), indir(dir),
randomize(randomize_), npasses(npasses_), file_pattern(pattern)
{
if (npasses == 0)
eblerror("number of passes must be >= 1");
out << "Initializing directory camera from: " << dir << std::endl;
fl = NULL;
if (files && files->size() > 0) // file names specified by hand
{ // build list and check each file exists
fl = new files_list;
for (std::list<std::string>::const_iterator i = files->begin();
i != files->end(); ++i)
{
std::string fullname;
fullname << dir << "/" << *i;
if (file_exists(fullname))
{
fl->push_back(stringpair(std::string(dir), *i));
}
else
e << "warning: file not found: " << fullname << std::endl;
}
if (fl->size() == 0)
{
err << "warning: No images in image list were found: "
<< *files << std::endl;
err << "Looking for other images..." << std::endl;
if (!read_directory(dir)) eblerror("No images found in " << dir);
}
}
else // search all files matching pattern
{
if (!read_directory(dir)) eblerror("No images found in " << dir);
}
std::cout << "Found " << fl->size() << " images in " << indir << std::endl;
if (randomize)
out << "Image list is randomized." << std::endl;
if (npasses > 1)
out << "Image list will be used " << npasses << " times." << std::endl;
flsize = fl->size() * npasses;
fli = fl->begin(); // initialize iterator to beginning
}
示例4: plugin_list
scheme_tree
plugin_list () {
bool flag;
array<string> a= read_directory ("$TEXMACS_PATH/plugins", flag);
a << read_directory ("/etc/TeXmacs/plugins", flag);
a << read_directory ("$TEXMACS_HOME_PATH/plugins", flag);
a << read_directory ("/usr/share/TeXmacs/plugins", flag);
merge_sort (a);
int i, n= N(a);
tree t (TUPLE);
for (i=0; i<n; i++)
if ((a[i] != ".") && (a[i] != "..") && ((i==0) || (a[i] != a[i-1])))
t << a[i];
return t;
}
示例5: fill_directory
static void fill_directory(struct dir_struct *dir, const char **pathspec,
int ignored_too)
{
const char *path, *base;
int baselen;
/* Set up the default git porcelain excludes */
memset(dir, 0, sizeof(*dir));
if (!ignored_too) {
dir->collect_ignored = 1;
setup_standard_excludes(dir);
}
/*
* Calculate common prefix for the pathspec, and
* use that to optimize the directory walk
*/
baselen = common_prefix(pathspec);
path = ".";
base = "";
if (baselen)
path = base = xmemdupz(*pathspec, baselen);
/* Read the directory and prune it */
read_directory(dir, path, base, baselen, pathspec);
if (pathspec)
prune_directory(dir, pathspec, baselen);
}
示例6: NOPH_Display_getDisplay
char *cibyl_select_game(char *base_dir)
{
NOPH_Display_t display = NOPH_Display_getDisplay(NOPH_MIDlet_get());
NOPH_Displayable_t cur = NOPH_Display_getCurrent(display);
NOPH_CommandMgr_t cm = NOPH_CommandMgr_getInstance();
char **p;
all_games = read_directory(get_current_directory());
if (!all_games)
return NULL;
game_list = NOPH_List_new("Select game", NOPH_Choice_IMPLICIT);
for (p = all_games; *p; p++)
{
NOPH_List_append(game_list, *p, 0);
}
NOPH_Display_setCurrent(display, game_list);
printf("Setting list\n");
NOPH_CommandMgr_setList(cm, game_list, select_game_callback, NULL);
while(selected_game == NULL)
{
NOPH_Thread_sleep(250);
}
free(all_games);
NOPH_Display_setCurrent(display, cur);
NOPH_delete(game_list);
game_list = 0;
return get_game_directory(selected_game);
}
示例7: wt_status_print_untracked
static void wt_status_print_untracked(struct wt_status *s)
{
struct dir_struct dir;
int i;
int shown_header = 0;
struct strbuf buf = STRBUF_INIT;
memset(&dir, 0, sizeof(dir));
if (!s->untracked) {
dir.show_other_directories = 1;
dir.hide_empty_directories = 1;
}
setup_standard_excludes(&dir);
read_directory(&dir, ".", "", 0, NULL);
for(i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
if (!cache_name_is_other(ent->name, ent->len))
continue;
if (!shown_header) {
s->workdir_untracked = 1;
wt_status_print_untracked_header(s);
shown_header = 1;
}
color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%s",
quote_path(ent->name, ent->len,
&buf, s->prefix));
}
strbuf_release(&buf);
}
示例8: cd
euint8 cd(euint8* FolderName)
{
SDfile File2[200];
SDfolder Folder2[200];
if(FolderName == "." )
return 0;
if(FolderName=="..")
{
return -1;
}
read_directory(File2,Folder2,currDir);
euint8* search = (euint8*)malloc(strlen(FolderName) - LastIndexOf('/',FolderName));
strCopyLen(FolderName,search,LastIndexOf('/',FolderName));
euint16 counter=0;
while(!(Folder2[counter].startH ==0 && Folder2[counter].startL==0)&&counter<20)
{
if(strcompare2(Folder2[counter].name,search)==0)
{
//we have found our folder
//now we need to update our pointers
currDir = Folder2[counter];
//free(search);
return 0;
}
++counter;
}
free(search);
return -1;
}
示例9: play_file
alt_8 play_file(char no_args, char* arg_strings[])
{
//first we need to open the file
if(no_args!=1)
{
UART_write("This needs a file name\r\n");
return -1;
}
euint8 FFound=0;
SDfile File[200];
SDfolder Folder[200];
read_directory(File,Folder,currDir);
euint16 i=0;
for(i=0;i<20;i++)
{
if(File[i].valid==1)
{
euint8 fname[15];
euint8 x=0,y=0;
for(x=0;x<8;x++)
{
if(File[i].name[x]!=0x20 && File[i].name[x]!=0x00)
{//if char is not null and is not space
fname[y] = File[i].name[x];
++y;
}
else
x=12;
}
fname[y]='.';
++y;
for(x=0;x<3;x++)
{
if(File[i].extension[x]!=0x20 && File[i].extension[x]!=0x00)
{//if char is not null and is not space
fname[y] = File[i].extension[x];
++y;
}
else
x=12;
}
//file is a valid file
fname[y]=0;//add null terminator
if(strcompare2(fname,arg_strings[0])==0)
{
FFound=1;
open_wav(File[i]);
}
}
}
/*
euint8 buffer[512];
read_file_chunk(File[6],buffer,512,0);
*/
if(FFound==0)
{
UART_write("That File cannot be found, check spelling and try again\r\n");
}
FFound=0;
}
示例10: main
/*
* Every sector of of the FAT holds 128 of these 32 bit integers, so looking up the next
* cluster of a file is relatively easy. Bits 7-31 of the current cluster tell you which sectors to read from the FAT, and bits
* 0-6 tell you which of the 128 integers in that sector contain is the number of the next cluster of your file (or if all ones, that the current cluster is the last).
*/
int main() {
uint8_t *buf = NULL;
int ret = 0;
if ((fp = fopen("/dev/sdb", "rb")) != NULL) {
if ((buf = malloc(MBR_SECTOR_SIZE)) != NULL) {
struct mbr_entry *mbr = NULL;
struct fat_info fti;
/* read the mbr */
if ((ret = read_sectors(0, 1, buf)) == 0) {
mbr = (struct mbr_entry *)(buf + MBR_OFFSET);
if ((ret = gen_fat_info(&fti, *mbr)) == 0) {
if ((ret = read_directory(fti)) != 0) {
printf("read_directory() failed with %i\n", ret);
}
} else {
printf("gen_fat_info() failed with %i\n", ret);
}
} else {
printf("read_sectors() failed with %i\n", ret);
}
} else {
printf("Unable to allocate %i bytes!\n", MBR_SECTOR_SIZE);
}
} else {
printf("Unable to open file!\n");
}
fclose(fp);
free(buf);
return 0;
}
示例11: main
int main(int argc, char *argv[]){
int file;
int read_dir;
if (argc != 2){
fprintf(stderr, "Usage: %s dir_name\n", argv[0]);
exit(1);
}
open("files.txt",O_TRUNC );
file = open("files.txt",O_WRONLY | O_APPEND | O_CREAT , S_IRWXG | S_IRWXU | S_IROTH);
if(file == -1){
perror("file ERROR");
close(file);
exit(1);
}
read_dir = read_directory(argv[1],file);
if(read_dir == 1){
perror(argv[1]);
close(file);
exit(2);
}else if(read_dir == 2){
perror("lstat ERROR");
close(file);
exit(3);
}
close(file);
execlp("sort", "sort", FILE_NAME,"-no", FILE_NAME, (char*)NULL);
exit(0);
}
示例12: wt_status_collect_untracked
void wt_status_collect_untracked(struct index_state *index,
GList **results,
const char *worktree,
IgnoreFunc ignore_func)
{
int i;
struct dir_struct dir;
DiffEntry *de;
memset(&dir, 0, sizeof(dir));
read_directory(&dir, worktree, index);
for (i = 0; i < dir.nr; i++) {
struct dir_entry *ent = dir.entries[i];
if (!ignore_func(ent->name, NULL)) {
unsigned char sha1[20] = { 0 };
de = diff_entry_new (DIFF_TYPE_WORKTREE, DIFF_STATUS_ADDED, sha1, ent->name);
*results = g_list_prepend (*results, de);
}
free(ent);
}
free(dir.entries);
}
示例13: do_delete_file
static void do_delete_file(UNUSED void *data)
{
int old_top_file, old_current_file;
char *ptr;
if (current_file < 0 || current_file >= flist.num_files)
return;
ptr = flist.files[current_file]->path;
/* would be neat to send it to the trash can if there is one */
unlink(ptr);
/* remember the list positions */
old_top_file = top_file;
old_current_file = current_file;
read_directory();
/* put the list positions back */
top_file = old_top_file;
current_file = old_current_file;
/* edge case: if this was the last file, move the cursor up */
if (current_file >= flist.num_files)
current_file = flist.num_files - 1;
file_list_reposition();
}
示例14: putty_ls
euint8 putty_ls()
{
SDfile File[20];
SDfolder Folder[20];
read_directory(File,Folder,currDir);
ls(File,Folder);
return 0;
}
示例15: showHiddenCB
void
showHiddenCB(Widget widget, XtPointer ignore,
XmToggleButtonCallbackStruct *callback_data)
{
showHidden = callback_data -> set;
read_directory((Widget) NULL, ".");
}