[ create a new paste ] login | about

Link: http://codepad.org/8WehiIB4    [ raw code | output | fork ]

C, pasted on Dec 3:
#include <sys/stat.h>
#include <stdio.h>
#include <time.h>

int main(int argc , char *argv[])
{
	struct stat buf;
	int i;
	
	if(argc < 2) {
		printf("ファイル名を指定して下さい。\n");
		return 1;
	}
	
	for(i=1; i<argc; i++) {
		printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");
		stat(argv[i], &buf);
		printf("ファイル名 : %s\n",argv[i]);
		printf("ファイルサイズ : %d bytes\n",buf.st_size);
		printf("ファイルの種類 : ");
		if( S_ISREG(buf.st_mode) ) printf("ファイル");
		else if( S_ISDIR(buf.st_mode) )  printf("ディレクトリ");
		else if( S_ISFIFO(buf.st_mode) ) printf("パイプ");
		else printf("ファイルでもディレクトリでもない");
		printf("\n");
		printf("最終変更時刻 : %s",ctime(&buf.st_mtime));
		printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \n");

	}
	return 0;
}


Output:
1
ファイル名を指定して下さい。


Create a new paste based on this one


Comments: