⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fexist.c

📁 seed格式数据解压程序,地震分析人员必备
💻 C
字号:
/*==========================================================================*//* DMC Interim out |                fexist.c                  |   Utility    *//*==========================================================================*//*	Name:	fexist.c		Purpose:combine input path name and file name to form an absolute file			name and test for its existence	Usage:	int fexist (char *path, char *file, char *name)			int ret			ret = fexist (path, file, name)	Input:	char *path 	ptr to path name		char *file	ptr to file name	Output:	char *name	ptr to absolute file name 		int fexist ()	= 0, file exists				= 1, file does not exist				= 2, file status error	Externals:Debug - setting of environment variable DEBUG (globals.h)	Messages:		Warnings:		Errors:			Fatals:			Called by:		Calls to:	Algorithm:		Notes:			Problems:		Debug:	level D_MIN - print out start and finish notices		level D_MED -		level D_MAX - print out absolute file name	References:	none	Language:	ANSI standard C, under Sun OS 3.5			EXCEPT:	calls system routine "stat"					uses include file <sys/types.h>					uses include file <sys/stat.h>					uses include file <errno.h>	Revisions:03/06/89  Kevin MacKenzie  original version*/                   /*=====================================*//*=================|                                       |=================*/                   /*=====================================*/#include "output.h"#include <sys/types.h>#include <sys/stat.h>#include <sys/param.h>#include <errno.h>int fexist (path, file, name)char *path;char *file;char *name;{	struct	stat	sbuf;	/* stat file status info */	int err;		/* result */	if (Debug >= D_MIN) fprintf (D_OUT, "[fexist] Started.\n");	sprintf (name, "%s/%s", path, file);	/* make full file name */	if (Debug >= D_MAX) 		fprintf (D_OUT, "[fexist] trying name = %s\n",name);	if ((stat (name, &sbuf)) == 0) err = 0;		/* file exists */	else if (errno == 2) err = 1;	/* file does not exist */	else err = 2;			/* odd status error */	if (Debug >= D_MIN) 		fprintf (D_OUT, "[fexist] Finished.\n");	return (err);}int is_dir(char *path, char *fname){	char full_fname[MAXPATHLEN];        struct stat sbuf;   /* stat file status info */	sprintf(full_fname, "%s/%s", path, fname);	if (stat(full_fname, &sbuf) == -1) /* file not there, ret false */	{		perror("is_dir()");		return 0;	}	return (sbuf.st_mode & S_IFDIR);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -