#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> /*----------------------------------------------------------------- functionname: file_exist param: NA return: NA author: xxxx check if file is exist in webapp history: create by xxxx, 2014.1.08, add simple abilities -------------------------------------------------------------*/ int file_exist(char* url) { int ret; int len = 0; char* path= NULL; if(url == NULL) return -1; len = strlen(url); if(len <= 0) return -1; path = (char*)malloc(len); strncpy(path, url, len); printf("[%s] ", path); // remove blanks on head and tailof url ret = access(path, R_OK); if(ret == -1) perror("uri not exist"); free(path); return ret; } long get_file_size(FILE* fs) { if(fs == NULL) return -1; fseek(fs, 0, SEEK_END); return ftell(fs); } char *itoa(int num, char *str, int radix) { //0的情况 if (num==0) { str[0]='0'; str[1]='