gfile.h
来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C头文件 代码 · 共 96 行
H
96 行
/* Copyright (C) 2006, Mike Gashler This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. see http://www.gnu.org/copyleft/lesser.html*/#ifndef __GFILE_H__#define __GFILE_H__#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>struct PathData{ int dirStart; int fileStart; int extStart; int len;};// Contains some useful routines for manipulating filesclass GFile{public: // returns true if the file exists static bool DoesFileExist(const char *filename); // returns true if the directory exists static bool DoesDirExist(const char* szDir); // This finds the last slash in szBuff and returns a // pointer to the char past that. (If there are no // slashes or back-slashes, it returns szBuff) static const char* ClipPath(const char* szBuff); // This finds the last slash in szBuff and sets it // to '\0' and returns szBuff. static char* ClipFilename(char* szBuff); // returns a user's home directory for the various OS's static bool GetGoodLocalStorageDirectory(char *toHere); // This copies a file. It doesn't check to see if it is // overwriting--it just does the copying. On success it // returns true. On error it returns false. It won't // work with a file bigger than 2GB. Both paths must // include the filename. static bool CpyFile(const char* szSrcPath, const char* szDestPath); // Loads a file into memory and returns a pointer to the // memory. You must delete the buffer it returns. static char* LoadFileToBuffer(const char* szFilename, int* pnSize); // Saves a buffer as a file. Returns true on success static bool SaveBufferToFile(unsigned char* pBuf, int nSize, const char* szFilename); // This is a brute force way to make a directory. It i // itterates through each subdir in szDir and calls mkdir // until it has created the complete set of nested directories. static bool MakeDir(char* szDir); // Remove extra ".." folders in the path static void CondensePath(char* szPath); // This returns the number of seconds since 1970 UTC static time_t GetModifiedTime(const char* szFilename); // Set the last modified time of a file static void SetModifiedTime(const char *filename, time_t t); // This only writes one pass of random numbers over the file, so it may still be // possible for the file to be recovered with expensive hardware that takes // advantage of the fact that the hard disk write head may drift slightly while // writing in order to read older data that may still be encoded along the edge // of the path on the platter. static bool ShredFile(const char* szFilename); // Delete a folder and recursively shred all it's contents. Returns true if successful // This only writes one pass of random numbers over the file--see the warning on // ShredFile. static bool ShredFolder(const char* szPath); // Identifies the folder, file, extension, and total length from a path static void ParsePath(const char* szPath, struct PathData* pData);};#endif // __GFILE_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?