C/C++ 判断路径为文件
/***************************************************
* 函数说明: 判断当前path参数是否为一个可读的文件
* 函数返回: 0 - 文件刻度 1 - 权限拒绝 -1 -函数错误
* 参 数 : path 文件路径.
***************************************************/
int isReadFile(const char *path)
{
struct stat info;
int euid,egid;
if ( 0!= stat(path,&info) )
{
return -1;
}
//if it is a file
if( S_IFREG != (info.st_mode & S_IFMT ) )
{
return 1;
}
euid=geteuid();//returns the real user ID of the
current process
egid=getegid();//returns the effective user ID of the
current process
//if effective user is root
if(euid==0)
{
if(info.st_mode & S_IRUSR || info.st_mode &
S_IRGRP ||info.st_mode & S_IROTH)
{
return 0;
}
相关文档:
什么是socket
长连接与短连接
所谓长连接,指在一个TCP连接上可以连续发送多个数据包,在TCP连接保持期间,如果没有数据包发送,需要双方发检测包以维持此连接,一般需要自己做在线维持。
短连接是指通信双方有数据交互时,就建立一个TCP连接,数据发送完成后,则断开此TCP连接,一般银行都使用短连接。
比如ht ......
yeah,组合的也出来了,再一起发一个
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication32
{
class Program
{
static int s = 0;
static void Main(string[] args)
{
Console.Writ ......
字符数组和字符串
&字符数组和字符串的概念 &字符数组的初始化
&字符串的输入输出 &综合举例
字符数组和字符串的概念
字符数组是元素类型为字符的数组 ,它既具有普通数组的一般性质 ,又具有某些特殊性质。
& ......
回忆C古老的math.h库
概述:
math.h中为我们提供了三角函数数值运算、指数对数运算、绝对值、平方值、以及一些基本的数值处理。
函数:sin
功能:计算弧度的正弦值。
使用说明:sin(x),x为传入的弧度值。
函数:cos
功能:计算弧度的余弦值。
使用说明:cos(x),x为传入的弧度值。
函数:tan
功能:计算弧度 ......
#include <list.h>
#include <dirent.h>
#include <iostream.h>
#include <sys/stat.h>
#include <sys/types.h>
/*****************************************************************
*函数功能: 目_录_遍_历.
*返回值: 成功返回0,失败返回非0.
*参数 path ......