标签: directory

如何统计linux下的文件夹数量?

如何统计桌面上的目录数量?我只得到文件夹列表,但我只需要文件夹的数量,我完全不明白该怎么做!:(

PS 不是文件,只有文件夹

谢谢你!

linux directory bash

-4
推荐指数
1
解决办法
1万
查看次数

Linux中最快的C代码以递归方式计算目录(无文件)

以下C代码将列出文件和目录的数量,并且比linux find命令快4倍。我只需要文件夹的数量,对文件数量甚至列出它们都不感兴趣。有没有一种方法可以优化以下代码并使之更高效?

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>

void listdir(char *path, size_t size) {
    DIR *dir;
    struct dirent *entry;
    size_t len = strlen(path);

    if (!(dir = opendir(path))) {
        fprintf(stderr, "path not found: %s: %s\n",
                path, strerror(errno));
        return;
    }

    puts(path);
    while ((entry = readdir(dir)) != NULL) {
        char *name = entry->d_name;
        if (entry->d_type == DT_DIR) {
            if (!strcmp(name, ".") || !strcmp(name, ".."))
                continue;
            if (len + strlen(name) + 2 > size) {
                fprintf(stderr, "path too …
Run Code Online (Sandbox Code Playgroud)

c linux directory recursion counting

-4
推荐指数
1
解决办法
110
查看次数

我的应用程序文档文件夹在XCode 9模拟器中的位置

它在哪里?我尝试了XCode 8的旧答案,它不在那里.为什么Apple让我们很难在模拟器中看到我们的应用程序的沙箱?

directory document ios-simulator xcode9

-5
推荐指数
3
解决办法
1万
查看次数

将目录和子目录列为带路径的数组;

我需要使用Perl列出存储在数组中的所有目录和子目录.

例如:

$array[0] = '/home';
$array[1] = '/home/ali';
$array[2] = '/home/perl';
$array[3] = '/home/stackoverflow';
$array[4] = '/home/ali/desktop';
$array[5] = '/home/ali/sub';
$array[6] = '/home/stackoverflow/new';
Run Code Online (Sandbox Code Playgroud)

arrays directory perl

-6
推荐指数
1
解决办法
6335
查看次数

标签 统计

directory ×4

linux ×2

arrays ×1

bash ×1

c ×1

counting ×1

document ×1

ios-simulator ×1

perl ×1

recursion ×1

xcode9 ×1