您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stat64函数代码示例

51自学网 2021-06-03 08:22:32
  C++
这篇教程C++ stat64函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中stat64函数的典型用法代码示例。如果您正苦于以下问题:C++ stat64函数的具体用法?C++ stat64怎么用?C++ stat64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了stat64函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FindNextFile

BOOL   FindNextFile(HANDLE hHandle, LPWIN32_FIND_DATA lpFindData){  if (lpFindData == NULL || hHandle == NULL || hHandle->GetType() != CXHandle::HND_FIND_FILE)    return FALSE;  if ((unsigned int) hHandle->m_nFindFileIterator >= hHandle->m_FindFileResults.size())    return FALSE;  CStdString strFileName = hHandle->m_FindFileResults[hHandle->m_nFindFileIterator++];  CStdString strFileNameTest = hHandle->m_FindFileDir + strFileName;  if (IsAliasShortcut(strFileNameTest))    TranslateAliasShortcut(strFileNameTest);  struct stat64 fileStat;  memset(&fileStat, 0, sizeof(fileStat));   if (stat64(strFileNameTest, &fileStat) == -1)    return FALSE;  bool bIsDir = false;  if (S_ISDIR(fileStat.st_mode))  {    bIsDir = true;  }  memset(lpFindData,0,sizeof(WIN32_FIND_DATA));  lpFindData->dwFileAttributes = FILE_ATTRIBUTE_NORMAL;  strcpy(lpFindData->cFileName, strFileName.c_str());  if (bIsDir)    lpFindData->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;  if (strFileName[0] == '.')    lpFindData->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;  if (access(strFileName, R_OK) == 0 && access(strFileName, W_OK) != 0)    lpFindData->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;  TimeTToFileTime(fileStat.st_ctime, &lpFindData->ftCreationTime);  TimeTToFileTime(fileStat.st_atime, &lpFindData->ftLastAccessTime);  TimeTToFileTime(fileStat.st_mtime, &lpFindData->ftLastWriteTime);  lpFindData->nFileSizeHigh = (DWORD)(fileStat.st_size >> 32);  lpFindData->nFileSizeLow =  (DWORD)fileStat.st_size;  return TRUE;}
开发者ID:A600,项目名称:xbmc,代码行数:49,


示例2: while

int eDVRPlayerThread::FillSliceSizes(){	slicesizes.clear();	struct stat64 s;	int filelength=0;	int slice = 0;	while (!stat64((filename + (slice ? eString().sprintf(".%03d", slice) : eString(""))).c_str(), &s))	{		filelength+=s.st_size/1880;		slicesizes.push_back(s.st_size);		slice++;	}	//eDebug("FillSliceSizes:%s,%d",filename.c_str(),filelength);	return filelength;}
开发者ID:UkCvs,项目名称:commando,代码行数:15,


示例3: os_file_type

int os_file_type(char *file){	struct stat64 buf;	if(stat64(file, &buf) == -1)		return(-errno);	if(S_ISDIR(buf.st_mode)) return(OS_TYPE_DIR);	else if(S_ISLNK(buf.st_mode)) return(OS_TYPE_SYMLINK);	else if(S_ISCHR(buf.st_mode)) return(OS_TYPE_CHARDEV);	else if(S_ISBLK(buf.st_mode)) return(OS_TYPE_BLOCKDEV);	else if(S_ISFIFO(buf.st_mode)) return(OS_TYPE_FIFO);	else if(S_ISSOCK(buf.st_mode)) return(OS_TYPE_SOCK);	else return(OS_TYPE_FILE);}
开发者ID:12019,项目名称:hg556a_source,代码行数:15,


示例4: VisItStat

intVisItStat(const char *file_name, VisItStat_t *buf){#if defined(_WIN32)   return _stat(file_name, buf);#else#if SIZEOF_OFF64_T > 4    return stat64(file_name, buf);#else    return stat(file_name, buf);#endif#endif}
开发者ID:HarinarayanKrishnan,项目名称:VisIt28RC_Trunk,代码行数:15,


示例5: verify_file

/* *  Verify that a file exists or can be created. */boolean_tverify_file(	const char *file,	/* file or directory name */	boolean_t dir_is_suff)	/* if true only directory must exist */{	char *dupfile;	char *path;	struct stat64 buf;	boolean_t rc = B_FALSE;	/*	 *	Must be a fully qualified path name.	 */	if (*file == '/') {		/*		 *	A file that already exists is good.		 */		if (stat64(file, &buf) == 0) {			rc = B_TRUE;		} else if (dir_is_suff) {			/*			 *	Check if valid directory.			 */			dupfile = strdup(file);			path = dirname(dupfile);			if (stat64(path, &buf) == 0) {				rc = B_TRUE;			}			free(dupfile);		}	}	return (rc);}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:39,


示例6: MYDEBUG

cFileInfo::cFileInfo(char *file){  MYDEBUG("FileInfo: %s", file);  File = (file && !isempty(file)) ? strdup(file) : NULL;  if(File && File[strlen(File) - 1] == '/')      File[strlen(File) - 1] = '/0';  buffer = NULL;  if(isExists())    stat64(File, &Info);  size = 0;}
开发者ID:suborb,项目名称:reelvdr,代码行数:15,


示例7: exists

// Returns true if file filename existsbool exists(const std::string &filename) {#ifdef _WIN32    std::wstring wstr = ConvertUTF8ToWString(filename);    return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF;#else    struct stat64 file_info;    std::string copy(filename);    stripTailDirSlashes(copy);    int result = stat64(copy.c_str(), &file_info);    return (result == 0);#endif}
开发者ID:Bublafus,项目名称:native,代码行数:16,


示例8: FileSize

	Uint64 FileSize(const QString & url)	{		int ret = 0;#ifdef HAVE_STAT64		struct stat64 sb;		ret = stat64(QFile::encodeName(url),&sb);#else		struct stat sb;		ret = stat(QFile::encodeName(url),&sb);#endif		if (ret < 0)			throw Error(i18n("Cannot calculate the filesize of %1: %2",url,strerror(errno)));		return (Uint64)sb.st_size;	}
开发者ID:dreamsxin,项目名称:libktorrent,代码行数:15,


示例9: List_files

int List_files(void){	int count,i;	struct direct **files;	struct stat64 finfo;	struct tm *pTime;	char	datebuff[30];	char	timebuff[30];		if (getcwd(pathname,sizeof(pathname)) == NULL )	{ 		printf("Error getting path /n");		return -1;	}	printf("Current Working Directory = %s /n",pathname);		count = scandir( pathname, &files, file_select, alphasort);	/* If no files found, make a non-selectable menu item */	if(count <= 0)	{		printf("No files in this directory /n");		return -1;	}		printf("/n"); 	for (i=0;i<count;i++)	{				if(!stat64(files[i]->d_name,&finfo))		{			pTime = localtime(&finfo.st_ctime);			sprintf(datebuff,"%d/%02d/%02d",(1900+pTime->tm_year),( 1+pTime->tm_mon), pTime->tm_mday);			sprintf(timebuff,"%02d:%02d:%02d",pTime->tm_hour, pTime->tm_min, pTime->tm_sec);			printf("%s	%s	%s	%dK /n",files[i]->d_name,datebuff,timebuff,(int)(finfo.st_size/1024));		}else{			printf("%s  /n",files[i]->d_name);		}			}		 	return count;}
开发者ID:NearZhxiAo,项目名称:3730,代码行数:48,


示例10: getTimeStamp

/** * Retrieve the size of a file from the file name.  If the * name is a device, it zero is returned. * * @param size   The returned size value. * * @return True if the size was retrievable, false otherwise. */bool SysFile::getTimeStamp(const char *name, const char *&time){    time = "";         // default return value    // the handle is not active, use the name    struct stat64 fileInfo;    if (stat64(name, &fileInfo) == 0)    {        // regular file?  return the defined size        if ((fileInfo.st_mode & (S_IFREG | S_IFDIR)) != 0)        {            time = ctime(&fileInfo.st_mtime);        }        return true;    }    return false;}
开发者ID:jlfaucher,项目名称:executor,代码行数:24,


示例11: itemCreated

 void itemCreated(const std::string& file) {     auto it = std::lower_bound(m_dirEntries.begin(), m_dirEntries.end(), file, Cmp());     it = m_dirEntries.emplace(it, file);          std::string filePatch = m_dir.path();     if (!endsWith(filePatch, '/'))         filePatch.push_back('/');     filePatch.append(file);     if (stat64(filePatch.c_str(), &it->info) == -1) {         m_dirEntries.erase(it);         return;     }          q->itemInserted(it - m_dirEntries.begin()); }
开发者ID:ccrtnsp,项目名称:ncxmms2,代码行数:16,


示例12: fileType

	FileType fileType(std::string const& filename)	{		struct stat64 file_stat;		if (stat64(filename.c_str(), &file_stat) == 0)		{			if (file_stat.st_mode & S_IFDIR)			{				return FileDirectory;			}			else if (file_stat.st_mode & S_IFREG)			{				return FileRegular;			}		}		return FileNotFound;	}
开发者ID:RuiVarela,项目名称:rengine,代码行数:16,


示例13: lastModified

   /**    *     Returns the time that the file denoted by this abstract pathname was last modified.    *    *     Returns:    *       A long value representing the time the file was last modified, measured in milliseconds    *       since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if    *       an I/O error occurs    */   uint64_t File::lastModified() {#ifdef __USE_LARGEFILE64      struct stat64 attrib;			// create a file attribute structure      if (stat64(myPathName.c_str(), &attrib) == 0) {		// get the attributes of myPathName#else      struct stat attrib;			// create a file attribute structure      if (stat(myPathName.c_str(), &attrib) == 0) {		// get the attributes of myPathName#endif         return (static_cast<uint64_t>(1000))*attrib.st_mtime;      } else  {            perror(std::string("error in File::lastModified() while trying to stat ").append(myPathName).c_str());            return 0;         }    }} // namespace bestofjava
开发者ID:nyllet,项目名称:bestofjava,代码行数:24,


示例14: isDirectory

bool Path::isDirectory() const{#if NORI_SYSTEM_WIN32    struct _stati64 sb;    if (_stati64(m_string.c_str(), &sb) != 0)        return false;#else    struct stat64 sb;    if (stat64(m_string.c_str(), &sb) != 0)        return false;#endif    return S_ISDIR(sb.st_mode) ? true : false;}
开发者ID:elmindreda,项目名称:Nori,代码行数:16,


示例15: chirp_fs_local_chmod

static INT64_T chirp_fs_local_chmod(const char *path, INT64_T mode){	PREAMBLE("chmod(`%s', 0o%" PRIo64 ")", path, mode);	struct stat64 linfo;	RESOLVE(path)	mode &= S_IXUSR|S_IRWXG|S_IRWXO; /* users can only set owner execute and group/other bits */	if (stat64(path, &linfo) == -1)		return -1;	if(S_ISDIR(linfo.st_mode)) {		mode |= S_IRWXU; /* all owner bits must be set */	} else {		mode |= S_IRUSR|S_IWUSR; /* owner read/write must be set */	}	rc = chmod(path, mode);	PROLOGUE}
开发者ID:NeilB879,项目名称:cctools,代码行数:16,


示例16: IsFileExists

int IsFileExists(const std::string& fname){	struct stat64 buff64;	int res = stat64(fname.c_str(), &buff64);	if (-1 != res)		return 0;	// No assertion if the path path does not exist.	if (ENOENT != errno) 	{		std::cout << "stat: " << fname << ": " << strerror(errno) << "[" << __FUNCTION__ << ":" << __LINE__ << "]" << std::endl;	}	return -1;}
开发者ID:zhangcunli,项目名称:cpp_daily,代码行数:16,


示例17: load

	int load(string backfile, string filename, FileBuffer *p, bool async)	{		struct stat64 st;		if (stat64(backfile.c_str() + 1, &st))		{			set_last_err_string("stat64 failure");			return -1;		}		p->unmapfile();		if (p->mapfile(backfile.substr(1), st.st_size))			return -1;		p->m_loaded = true;		return 0;	}
开发者ID:NXPmicro,项目名称:mfgtools,代码行数:16,


示例18: isFile

bool Path::isFile() const{#if WENDY_SYSTEM_WIN32  struct _stati64 sb;  if (_stati64(path.c_str(), &sb) != 0)    return false;#else  struct stat64 sb;  if (stat64(path.c_str(), &sb) != 0)    return false;#endif  return S_ISREG(sb.st_mode) ? true : false;}
开发者ID:r-lyeh-forks,项目名称:Wendy,代码行数:16,


示例19: find_gwin

static intfind_gwin(gwin_query_t *gqp, const lwpstatus_t *psp){	gwindows_t gwin;	struct stat64 st;	char path[64];	ssize_t n;	int fd, i;	int rv = 0; /* Return value for skip to next lwp */	(void) snprintf(path, sizeof (path), "/proc/%d/lwp/%d/gwindows",	    (int)gqp->gq_proc->pid, (int)psp->pr_lwpid);	if (stat64(path, &st) == -1 || st.st_size == 0)		return (0); /* Nothing doing; skip to next lwp */	if ((fd = open64(path, O_RDONLY)) >= 0) {		/*		 * Zero out the gwindows_t because the gwindows file only has		 * as much data as needed to represent the saved windows.		 */		(void) memset(&gwin, 0, sizeof (gwin));		n = read(fd, &gwin, sizeof (gwin));		if (n > 0) {			/*			 * If we actually found a non-zero gwindows file and			 * were able to read it, iterate through the buffers			 * looking for a stack pointer match; if one is found,			 * copy out the corresponding register window.			 */			for (i = 0; i < gwin.wbcnt; i++) {				if (gwin.spbuf[i] == (greg_t *)gqp->gq_addr) {					(void) memcpy(gqp->gq_rwin,					    &gwin.wbuf[i],					    sizeof (struct rwindow));					rv = 1; /* We're done */					break;				}			}		}		(void) close(fd);	}	return (rv);}
开发者ID:kele,项目名称:illumos-fsd,代码行数:47,


示例20: test_if_raw

/* * test the path/fname to see if is char special */static inttest_if_raw(char *new_path, dev_t blk_dev){	struct stat64	buf;	/* check if we got a char special file */	if (stat64(new_path, &buf) != 0)		return (0);	if (!S_ISCHR(buf.st_mode))		return (0);	if (blk_dev != buf.st_rdev)		return (0);	return (1);}
开发者ID:andreiw,项目名称:polaris,代码行数:20,


示例21: NaClHostDescStat

/* * This is not a host descriptor function, but is closely related to * fstat and should behave similarly. */int NaClHostDescStat(char const       *host_os_pathname,                     nacl_host_stat_t *nhsp) {#if NACL_LINUX  if (stat64(host_os_pathname, nhsp) == -1) {    return -errno;  }#elif NACL_OSX  if (stat(host_os_pathname, nhsp) == -1) {    return -errno;  }#else# error "What OS?"#endif  return 0;}
开发者ID:camuel,项目名称:zvm,代码行数:21,


示例22: tb_file_info

tb_bool_t tb_file_info(tb_char_t const* path, tb_file_info_t* info){    // check    tb_assert_and_check_return_val(path, tb_false);    // the full path (need translate "~/")    tb_char_t full[TB_PATH_MAXN];    path = tb_path_absolute(path, full, TB_PATH_MAXN);    tb_assert_and_check_return_val(path, tb_false);    // exists?    tb_check_return_val(!access(path, F_OK), tb_false);    // get info    if (info)    {        // init info        tb_memset(info, 0, sizeof(tb_file_info_t));        // get stat#ifdef TB_CONFIG_POSIX_HAVE_STAT64        struct stat64 st = {0};        if (!stat64(path, &st))#else        struct stat st = {0};        if (!stat(path, &st))#endif        {            // file type            if (S_ISDIR(st.st_mode)) info->type = TB_FILE_TYPE_DIRECTORY;            else info->type = TB_FILE_TYPE_FILE;            // file size            info->size = st.st_size >= 0? (tb_hize_t)st.st_size : 0;            // the last access time            info->atime = (tb_time_t)st.st_atime;            // the last modify time            info->mtime = (tb_time_t)st.st_mtime;        }    }    // ok    return tb_true;}
开发者ID:ljx0305,项目名称:tbox,代码行数:46,


示例23: vm_file_getinfo

/* obtain file info. return 0 if file is not accessible,   file_size or file_attr can be NULL if either is not interested */Ipp32s vm_file_getinfo(const vm_char *filename, Ipp64u *file_size, Ipp32u *file_attr) {#if defined(OSX) || defined(LINUX64)   struct stat buf;   if (stat(filename,&buf) != 0) return 0;#else   struct stat64 buf;   if (stat64(filename,&buf) != 0) return 0;#endif   if (file_size) *file_size=buf.st_size;   if (file_attr) {      *file_attr=0;      if (buf.st_mode & S_IFREG) *file_attr|=VM_FILE_ATTR_FILE;      if (buf.st_mode & S_IFDIR) *file_attr|=VM_FILE_ATTR_DIRECTORY;      if (buf.st_mode & S_IFLNK) *file_attr|=VM_FILE_ATTR_LINK;   }   return 1;}
开发者ID:james1023,项目名称:com_interface,代码行数:19,


示例24: Exists

// Returns true if file filename exists. Will return true on directories.bool Exists(const std::string &filename) {	std::string fn = filename;	StripTailDirSlashes(fn);#if defined(_WIN32)	std::wstring copy = ConvertUTF8ToWString(fn);	// Make sure Windows will no longer handle critical errors, which means no annoying "No disk" dialog	int OldMode = SetErrorMode(SEM_FAILCRITICALERRORS);	bool success = GetFileAttributes(copy.c_str()) != INVALID_FILE_ATTRIBUTES;	SetErrorMode(OldMode);	return success;#else	struct stat64 file_info;	return stat64(fn.c_str(), &file_info) == 0;#endif}
开发者ID:AdmiralCurtiss,项目名称:ppsspp,代码行数:18,


示例25: statvfs

intstatvfs (const char *file, struct statvfs *buf){  struct statfs fsbuf;  struct stat64 st;  /* Get as much information as possible from the system.  */  if (__statfs (file, &fsbuf) < 0)    return -1;  /* Convert the result.  */  __internal_statvfs (file, buf, &fsbuf,		      stat64 (file, &st) == -1 ? NULL : &st);  /* We signal success if the statfs call succeeded.  */  return 0;}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,


示例26: GetFileSize

// Returns the size of filename (64bit)u64 GetFileSize(const std::string &filename) {    if (!FileExists(filename)) {        LOG_WARNING(TCOMMON, "GetSize: failed %s: No such file", filename.c_str());        return 0;    }    if (IsDirectory(filename)) {        LOG_WARNING(TCOMMON, "GetSize: failed %s: is a directory", filename.c_str());        return 0;    }    struct stat64 buf;    if (stat64(filename.c_str(), &buf) == 0) {        LOG_DEBUG(TCOMMON, "GetSize: %s: %lld", filename.c_str(), (long long)buf.st_size);        return buf.st_size;    }    LOG_ERROR(TCOMMON, "GetSize: Stat failed %s", filename.c_str());    return 0;}
开发者ID:TechnoCrunch,项目名称:ReGekko,代码行数:18,


示例27: fs_volexist

/* * fs_volexist * * Check if the volume exists */boolean_tfs_volexist(char *path){	struct stat64 st;	char *p;	if ((p = get_volname(path)) == NULL)		return (FALSE);	if (stat64(p, &st) != 0) {		free(p);		return (FALSE);	}	free(p);	return (TRUE);}
开发者ID:metricinc,项目名称:illumos-gate,代码行数:22,


示例28: quickdir_change

int quickdir_change(mvp_widget_t *widget,char *path ){	int rc;	struct stat64 sb;	rc = stat64(path, &sb);	if (rc==0) {		if (strstr(path,"/uPnP")!=NULL && strstr(cwd,"/uPnP")==NULL ){			mount_djmount(path);						} else if (strstr(path,"/uPnP")==NULL && strstr(cwd,"/uPnP")!=NULL ) { 			unmount_djmount();		}		snprintf(cwd,1024,"%s",path);		fb_update(widget);	}	return rc;}
开发者ID:gettler,项目名称:mvpmc,代码行数:17,


示例29: select_file

char * select_file(char *input, int what_help){	char **list = NULL, *isdir = NULL, *path = NULL;	char *new_fname = NULL;	struct stat64 statbuf;	int list_n, index;	int strbufsize = find_path_max();	list_n = match_files(input, &path, &list, &isdir);	if (list_n == 0)	{		myfree(path);		flash();		return NULL;	}	index = selection_box((void **)list, isdir, list_n, SEL_FILES, what_help, NULL);	if (index != -1)	{		new_fname = (char *)mymalloc(strbufsize + 1);		snprintf(new_fname, strbufsize, "%s%s", path, list[index]);		if (stat64(new_fname, &statbuf) == -1)		{			myfree(new_fname);			new_fname = NULL;			flash();		}		else		{			if (S_ISDIR(statbuf.st_mode))			{				strncat(new_fname, "/", strbufsize);			}		}	}	delete_array(list, list_n);	myfree(isdir);	myfree(path);	return new_fname;}
开发者ID:BADSEC,项目名称:multitail,代码行数:45,



注:本文中的stat64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ statLine函数代码示例
C++ stat函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。