hewei.it %!s(int64=4) %!d(string=hai) anos
pai
achega
794194ef28
Modificáronse 6 ficheiros con 8 adicións e 8 borrados
  1. 1 1
      examples/httpd/handler.h
  2. 2 2
      http/HttpMessage.h
  3. 1 1
      http/http_content.cpp
  4. 2 2
      protocol/ftp.c
  5. 1 1
      unittest/md5_test.c
  6. 1 1
      unittest/sha1_test.c

+ 1 - 1
examples/httpd/handler.h

@@ -177,7 +177,7 @@ public:
         }
         }
         string filepath("html/uploads/");
         string filepath("html/uploads/");
         filepath += file.filename;
         filepath += file.filename;
-        FILE* fp = fopen(filepath.c_str(), "w");
+        FILE* fp = fopen(filepath.c_str(), "wb");
         if (fp) {
         if (fp) {
             fwrite(file.content.data(), 1, file.content.size(), fp);
             fwrite(file.content.data(), 1, file.content.size(), fp);
             fclose(fp);
             fclose(fp);

+ 2 - 2
http/HttpMessage.h

@@ -208,7 +208,7 @@ public:
 
 
     int File(const char* filepath) {
     int File(const char* filepath) {
         HFile file;
         HFile file;
-        if (file.open(filepath, "r") != 0) {
+        if (file.open(filepath, "rb") != 0) {
             return HTTP_STATUS_NOT_FOUND;
             return HTTP_STATUS_NOT_FOUND;
         }
         }
         const char* suffix = hv_suffixname(filepath);
         const char* suffix = hv_suffixname(filepath);
@@ -236,7 +236,7 @@ public:
             return HTTP_STATUS_BAD_REQUEST;
             return HTTP_STATUS_BAD_REQUEST;
         }
         }
         HFile file;
         HFile file;
-        if (file.open(filepath, "w") != 0) {
+        if (file.open(filepath, "wb") != 0) {
             return HTTP_STATUS_INTERNAL_SERVER_ERROR;
             return HTTP_STATUS_INTERNAL_SERVER_ERROR;
         }
         }
         file.write(formdata.content.data(), formdata.content.size());
         file.write(formdata.content.data(), formdata.content.size());

+ 1 - 1
http/http_content.cpp

@@ -79,7 +79,7 @@ std::string dump_multipart(MultiPart& mp, const char* boundary) {
         if (form.filename.size() != 0) {
         if (form.filename.size() != 0) {
             if (form.content.size() == 0) {
             if (form.content.size() == 0) {
                 HFile file;
                 HFile file;
-                if (file.open(form.filename.c_str(), "r") == 0) {
+                if (file.open(form.filename.c_str(), "rb") == 0) {
                     file.readall(form.content);
                     file.readall(form.content);
                 }
                 }
             }
             }

+ 2 - 2
protocol/ftp.c

@@ -191,7 +191,7 @@ int ftp_upload(ftp_handle_t* hftp, const char* local_filepath, const char* remot
     //printf("< %s", hftp->recvbuf);
     //printf("< %s", hftp->recvbuf);
     {
     {
         // you can create thread to send data
         // you can create thread to send data
-        FILE* fp = fopen(local_filepath, "r");
+        FILE* fp = fopen(local_filepath, "rb");
         if (fp == NULL) {
         if (fp == NULL) {
             closesocket(sockfd);
             closesocket(sockfd);
             return ERR_OPEN_FILE;
             return ERR_OPEN_FILE;
@@ -232,7 +232,7 @@ static int s_ftp_download_cb(ftp_handle_t* hftp, char* buf, int len) {
 
 
 // remote => local
 // remote => local
 int ftp_download(ftp_handle_t* hftp, const char* remote_filepath, const char* local_filepath) {
 int ftp_download(ftp_handle_t* hftp, const char* remote_filepath, const char* local_filepath) {
-    FILE* fp = fopen(local_filepath, "w");
+    FILE* fp = fopen(local_filepath, "wb");
     if (fp == NULL) {
     if (fp == NULL) {
         return ERR_OPEN_FILE;
         return ERR_OPEN_FILE;
     }
     }

+ 1 - 1
unittest/md5_test.c

@@ -24,7 +24,7 @@ int main(int argc, char* argv[]) {
 
 
     if (argc == 2) {
     if (argc == 2) {
         const char* filepath = argv[1];
         const char* filepath = argv[1];
-        FILE* fp = fopen(filepath, "r");
+        FILE* fp = fopen(filepath, "rb");
         if (fp == NULL) {
         if (fp == NULL) {
             printf("Open file '%s' failed!\n", filepath);
             printf("Open file '%s' failed!\n", filepath);
             return -20;
             return -20;

+ 1 - 1
unittest/sha1_test.c

@@ -24,7 +24,7 @@ int main(int argc, char* argv[]) {
 
 
     if (argc == 2) {
     if (argc == 2) {
         const char* filepath = argv[1];
         const char* filepath = argv[1];
-        FILE* fp = fopen(filepath, "r");
+        FILE* fp = fopen(filepath, "rb");
         if (fp == NULL) {
         if (fp == NULL) {
             printf("Open file '%s' failed!\n", filepath);
             printf("Open file '%s' failed!\n", filepath);
             return -20;
             return -20;