25 #ifndef CURL_DISABLE_FILE 27 #ifdef HAVE_NETINET_IN_H 28 #include <netinet/in.h> 33 #ifdef HAVE_ARPA_INET_H 34 #include <arpa/inet.h> 39 #ifdef HAVE_SYS_IOCTL_H 40 #include <sys/ioctl.h> 43 #ifdef HAVE_SYS_PARAM_H 44 #include <sys/param.h> 69 #if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || \ 70 defined(__SYMBIAN32__) 71 #define DOS_FILESYSTEM 1 74 #ifdef OPEN_NEEDS_ARG3 75 # define open_readonly(p,f) open((p),(f),(0)) 77 # define open_readonly(p,f) open((p),(f)) 89 bool dead_connection);
147 while(*ptr && (
ISSPACE(*ptr) || (*ptr ==
'-')))
198 #ifdef DOS_FILESYSTEM 202 size_t real_path_len;
205 &real_path_len,
FALSE);
209 #ifdef DOS_FILESYSTEM 224 actual_path = real_path;
225 if((actual_path[0] ==
'/') &&
227 (actual_path[2] ==
':' || actual_path[2] ==
'|')) {
228 actual_path[2] =
':';
234 for(i = 0; i < real_path_len; ++
i)
235 if(actual_path[i] ==
'/')
236 actual_path[
i] =
'\\';
237 else if(!actual_path[i]) {
243 file->
path = actual_path;
245 if(memchr(real_path, 0, real_path_len)) {
252 file->
path = real_path;
286 bool dead_connection)
289 (void)dead_connection;
302 #ifdef DOS_FILESYSTEM 336 #define MODE_DEFAULT O_WRONLY|O_CREAT|O_BINARY 338 #define MODE_DEFAULT O_WRONLY|O_CREAT 348 failf(data,
"Can't open %s for writing", file->
path);
358 if(fstat(fd, &file_stat)) {
360 failf(data,
"Can't get the size of %s", file->
path);
375 nread = (
size_t)readcount;
394 nwrite = write(fd, buf2, nread);
395 if(nwrite != nread) {
438 bool fstated =
FALSE;
460 if(-1 != fstat(fd, &statbuf)) {
462 expected_size = statbuf.st_size;
481 const struct tm *tm = &
buffer;
490 (
char *)
"Accept-ranges: bytes\r\n", 0);
494 filetime = (time_t)statbuf.st_mtime;
501 "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
523 failf(data,
"Can't get the size of file.");
532 failf(data,
"failed to resume file:// transfer");
540 if(!fstated || (expected_size == 0))
571 nread = read(fd, buf, bytestoread);
576 if(nread <= 0 || (size_known && (expected_size == 0)))
581 expected_size -= nread;
static CURLcode file_done(struct connectdata *conn, CURLcode status, bool premature)
static CURLcode file_disconnect(struct connectdata *conn, bool dead_connection)
CURLcode Curl_urldecode(struct Curl_easy *data, const char *string, size_t length, char **ostring, size_t *olen, bool reject_ctrl)
const char *const Curl_wkday[]
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
#define PROTOPT_NOURLQUERY
const char *const Curl_month[]
UNITTEST_START char * ptr
CURLcode Curl_initinfo(struct Curl_easy *data)
void Curl_pgrsStartNow(struct Curl_easy *data)
UNITTEST_START int result
static srvr_sockaddr_union_t from
static CURLcode file_do(struct connectdata *, bool *done)
int Curl_pgrsUpdate(struct connectdata *conn)
static CURLcode file_range(struct connectdata *conn)
#define open_readonly(p, f)
curl_easy_setopt expects a curl_off_t argument for this option curl_easy_setopt expects a curl_write_callback argument for this option curl_easy_setopt expects a curl_ioctl_callback argument for this option curl_easy_setopt expects a curl_opensocket_callback argument for this option curl_easy_setopt expects a curl_debug_callback argument for this option curl_easy_setopt expects a curl_conv_callback argument for this option curl_easy_setopt expects a private data pointer as argument for this option curl_easy_setopt expects a FILE *argument for this option curl_easy_setopt expects a struct curl_httppost *argument for this option curl_easy_setopt expects a struct curl_slist *argument for this option curl_easy_getinfo expects a pointer to char *for this info curl_easy_getinfo expects a pointer to double for this info curl_easy_getinfo expects a pointer to struct curl_tlssessioninfo *for this info curl_easy_getinfo expects a pointer to curl_socket_t for this info size_t
static CURLcode file_connect(struct connectdata *conn, bool *done)
static CURLcode file_setup_connection(struct connectdata *conn)
CURLofft curlx_strtoofft(const char *str, char **endp, int base, curl_off_t *num)
bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc)
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
CURL_TYPEOF_CURL_OFF_T curl_off_t
CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
CURLcode Curl_speedcheck(struct Curl_easy *data, struct curltime now)
CURLcode Curl_client_write(struct connectdata *conn, int type, char *ptr, size_t len)
#define Curl_safefree(ptr)
#define PROTOPT_NONETWORK
const struct Curl_handler Curl_handler_file
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
CURLcode Curl_gmtime(time_t intime, struct tm *store)
curl_TimeCond timecondition
static CURLcode file_upload(struct connectdata *conn)
size_t curlx_sotouz(curl_off_t sonum)
#define calloc(nbelem, size)
#define CURL_FORMAT_CURL_OFF_T