C/C++の宿題を片付けます 86代目
■ このスレッドは過去ログ倉庫に格納されています
0486デフォルトの名無しさん
2007/05/03(木) 00:23:13こんな感じの処理を組み込めばディレクトリの場合だけ(その逆も)なんかの処理をするというのは可能なはず
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void)
{
char *path = "./hoge"; /* file name */
struct stat st;
stat(path, &st); /* get information */
if (S_ISDIR(st.st_mode))
{
puts("\"path\" is directory");
} else
{
puts("\"path\" is file or something else");
}
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています