c++ utf8 unicode ansi 互转
摘要:#include <codecvt> std::string UnicodeToUTF8(const std::wstring & wstr){ std::string ret; try { std::wstring_convert< std::codecvt_utf8<wchar_t> > wcv
阅读全文
检测磁盘空间,删除指定类型最早创建的文件
摘要:#!/bin/bashwhile [ 1 ]do sleep 30 avail=`df / -h | awk '{print $4}' | awk '{sum+=$1}END{print sum}'` echo "disk avail:"$avail"G" if [ $avail -lt 5 ] t
阅读全文
LINUX C ANSI 转 UTF8
摘要://iconv_linux下字符集编码转换轻松实现 (1) iconv_t iconv_open(const char *tocode, const char *fromcode); //此函数说明将要进行哪两种编码的转换,tocode是目标编码,fromcode是原编码,该函数返回一个转换句柄,供
阅读全文
linux-内存分布测试
摘要:#include <stdio.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <time.h> #include <stdlib.h> #include <pthread.h> /* int new_si
阅读全文
linux-线程资源释放-线程属性-exit资源释放规律
摘要:#include <stdio.h> #include <string.h> #include <fcntl.h> #include <unistd.h> #include <time.h> #include <stdlib.h> #include <pthread.h> #include <err
阅读全文
linux-udp-客户端服务器结合体
摘要:////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
阅读全文
Linux下多线程程序消耗虚拟内存测试
摘要:////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
阅读全文
Linux下查找一个文件的所有软硬链接-硬链接与软链接的区别
摘要:硬链接(Hard Link): 硬连接指通过索引节点来进行链接(即一个指针指向文件索引节点)。在Linux的文件系统中,保存在磁盘分区中的文件不管是什么类型都给它分配一个编号,称为索引节点号(Inode Index)。在Linux中,多个文件名指向同一索引节点是存在的。一般这种链接就是硬链接。硬链接
阅读全文
linux 管道通信 之 不通脚本间通信示例
摘要:#!/bin/bash # filename: reader.sh # 逐行读取管道中的内容 pipe=/tmp/testpipe trap "rm -f $pipe" EXIT if [[ ! -p $pipe ]]; then mkfifo $pipe fi while true do if r
阅读全文
linux u盘自动挂载 自动拷贝u盘数据 热插拔
摘要:udev 设备管理器 Udev 是 Linux 2.6 内核的设备管理器,它动态地在 /dev 目录中创建/删除设备节点。它是 devfs 和 hotplug 的继承者。它在用户空间运行,用户可以使用 Udev 规则更改设备名称。 Udev 依赖于 2.5 内核中引入的 sysfs 文件系统。sys
阅读全文
linux c 获取当前日期时间
摘要:struct tm nowtime;struct timeval tv;unsigned char time_now[128];gettimeofday(&tv, NULL);localtime_r(&tv.tv_sec,&nowtime); sprintf(time_now,"%d-%d-%d %
阅读全文