static int walk_tree(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage, void *cbdata) { if (baselen == match_baselen) { if (S_ISREG(mode)) print_object(sha1, pathname); else if (S_ISDIR(mode)) { print_dir(sha1, pathname, base); return READ_TREE_RECURSIVE; } } else if (baselen > match_baselen) print_dir_entry(sha1, pathname, mode); else if (S_ISDIR(mode)) return READ_TREE_RECURSIVE; return 0; }
void list_files(ext2_directory_t *dir, uint32_t len) { while(len > 0) { if(dir[0].inode == 0) { len -= dir[0].rec_len; dir = (ext2_directory_t *)((uint8_t *)dir + dir[0].rec_len); continue; } print_dir_entry((ext2_directory_t *)dir); len -= dir[0].rec_len; dir = (ext2_directory_t *)((uint8_t *)dir + dir[0].rec_len); } }
void print_root_dir(struct fat16_filesystem * fs) { struct fat_dir_entry entry; int i; fat_seek_to_root_dir(fs); putchar('\n'); printf("Root directory:\n"); for (i = 0; i < fs->root_dir_entries; i++) { fread(&entry, sizeof(entry), 1, fs->fd); /* skip empty/unused entries */ if (!fat_dir_entry_exists(&entry)) continue; /* skip volume label */ if (fat_is_volume_label(&entry)) continue; print_dir_entry(fs, &entry); } }
static int walk_tree(const unsigned char *sha1, struct strbuf *base, const char *pathname, unsigned mode, int stage, void *cbdata) { struct walk_tree_context *walk_tree_ctx = cbdata; if (base->len == walk_tree_ctx->match_baselen) { if (S_ISREG(mode)) { if (print_object(sha1, pathname)) walk_tree_ctx->match = 1; } else if (S_ISDIR(mode)) { print_dir(sha1, base->buf, base->len, pathname); walk_tree_ctx->match = 2; return READ_TREE_RECURSIVE; } } else if (base->len > walk_tree_ctx->match_baselen) { print_dir_entry(sha1, base->buf, base->len, pathname, mode); walk_tree_ctx->match = 2; } else if (S_ISDIR(mode)) { return READ_TREE_RECURSIVE; } return 0; }