
linux C++
heihei36
这个作者很懒,什么都没留下…
展开
-
关于gcc 5.5.0关于宏展开的BUG
gcc版本:5.5.0 vs版本:vs 2015 如下宏定义代码 #define LOGDEBUG(format, ...) fprintf(stdout, "DEBUG file:%s, line:%d, msg: " format"\n", __FILE__, __LINE__, ##__VA_ARGS__) //#define LOGDEBUG(format, args...) fprintf(stdout, "DEBUG file:%s, line:%d, msg: " format"\n"原创 2021-01-13 18:55:50 · 304 阅读 · 0 评论 -
linux c copyFile接口实现
LINUX本身并不提供拷贝文件的接口,于是自己实现了一个。int copyFile(const char* src, const char* des) { int nRet = 0; FILE* pSrc = NULL, *pDes = NULL; pSrc = fopen(src, "r"); pDes = fopen(des, "w+"); if (pSrc && pDes)原创 2017-10-30 14:00:23 · 4063 阅读 · 0 评论 -
linux c 创建多级目录接口实现
void casMkdir(const char* dir) { int nIndex = 1; char* tmp = (char*)dir; while ( nIndex < strlen(dir) + 1 ) { if (*(dir+nIndex) == '/' || *(dir+nIndex) == '\0') { char parent[256] = {0};原创 2017-10-30 14:04:54 · 1249 阅读 · 0 评论 -
linux C++ Utf8toGb2312 Gb2312toUtf8 MyA2W和MyW2A实现
CHealper.h #ifndef __CHELPER_H__ #define __CHELPER_H__ #include int Utf8toGb2312(const char *sourcebuf, size_t sourcelen, char *destbuf, size_t* destlen); int Gb2312toUtf8(const char *sourcebuf, s原创 2017-09-01 09:25:03 · 888 阅读 · 0 评论 -
LINUX C++ 按修改时间清理过期文件函数实现
#define _IS_DIR_ 0x4 #define _IS_FILE_ 0x8 void DeleteFolder(const char* dir, int nSpanTime) { if (dir == nullptr || strlen(dir) <= 0) return; struct stat s; lstat(dir, &s); if ( !S_ISDIR(s.st_mo原创 2017-12-09 18:37:20 · 1021 阅读 · 0 评论 -
linux c删除超时文件包括空目录
bool DeleteTimeOutFile(const char* dir, int nSpanTime) { if (dir == nullptr || strlen(dir) <= 0) return false; struct stat s; //lstat(dir, &s); stat(dir, &s); if (!S_ISDIR(s.st_mode))...原创 2018-03-08 17:29:01 · 505 阅读 · 0 评论 -
LINUX能new最大空间是多少?
new最大空间大小 = 操作系统剩余内存大小 + 操作系统剩余交换分区大小 另外,在测试过程中发现以下问题是我之前没注意到的,或者说是没细想过的: 1、单纯的new是不会实际占用内存空间的,只要等到真正的用到时才会占用内存空间。 2、new申请的超出最大空间(剩余内存大小 + 剩余交换分区大小)后,才会报出异常且得到一个空指针。 3、int64_t nSize = 1024 * 10...原创 2018-10-25 14:50:33 · 2659 阅读 · 1 评论