myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [3061] Code refactoring, some methods were renamed and


From: Giuseppe Scrivano
Subject: [myserver-commit] [3061] Code refactoring, some methods were renamed and file are copied by blocks of 4Kb.
Date: Tue, 28 Apr 2009 10:07:55 +0000

Revision: 3061
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=3061
Author:   gscrivano
Date:     2009-04-28 10:07:55 +0000 (Tue, 28 Apr 2009)
Log Message:
-----------
Code refactoring, some methods were renamed and file are copied by blocks of 
4Kb.

Modified Paths:
--------------
    trunk/myserver/include/base/file/files_utility.h
    trunk/myserver/src/base/file/files_utility.cpp
    trunk/myserver/src/protocol/ftp/ftp.cpp

Modified: trunk/myserver/include/base/file/files_utility.h
===================================================================
--- trunk/myserver/include/base/file/files_utility.h    2009-04-28 10:07:49 UTC 
(rev 3060)
+++ trunk/myserver/include/base/file/files_utility.h    2009-04-28 10:07:55 UTC 
(rev 3061)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 3 of the License, or
@@ -92,13 +92,14 @@
   static void getFilename(const char* path, char* filename);
   static void getFilename(string const &path, string& filename);
 
-  static int simpleMakeDirectory(const char *path);
-  static int deleteDirectory(const char *path);
-  static int simpleMakeDirectory(string const &path)
-  { return simpleMakeDirectory(path.c_str()); }
-  static int deleteDirectory(string const &path)
-  { return deleteDirectory(path.c_str()); }
+  static int rmdir (const char *path);
+  static int rmdir (string const &path)
+  { return rmdir (path.c_str()); }
 
+  static int mkdir (const char *path);
+  static int mkdir (string const &path)
+  { return mkdir (path.c_str()); }
+
   static void temporaryFileName(u_long tid, string &out);
 
   static void resetTmpPath();

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp      2009-04-28 10:07:49 UTC 
(rev 3060)
+++ trunk/myserver/src/base/file/files_utility.cpp      2009-04-28 10:07:55 UTC 
(rev 3061)
@@ -212,14 +212,14 @@
  */
 int FilesUtility::copyFile(File src, File dest)
 {
-  char buffer[512];
+  char buffer[4096];
   u_long nbr, nbw;
   int ret;
 
 
   for (;;) 
   {
-    ret = src.read(buffer, 512, &nbr);
+    ret = src.read(buffer, 4096, &nbr);
     if (ret)
       return -1;
     
@@ -747,12 +747,12 @@
  *Return non-zero on errors.
  *\param path The path to the directory to create.
  */
-int FilesUtility::simpleMakeDirectory(const char *path)
+int FilesUtility::mkdir (const char *path)
 {
 #ifdef WIN32
   return CreateDirectory(path, NULL)?0:-1;
 #else
-  return mkdir(path, S_IRUSR | S_IWUSR);
+  return ::mkdir(path, S_IRUSR | S_IWUSR);
 #endif
 }
 
@@ -762,12 +762,12 @@
  *Return non-zero on errors.
  *\param path The directory to remove.
  */
-int FilesUtility::deleteDirectory(const char *path)
+int FilesUtility::rmdir (const char *path)
 {
 #ifdef WIN32
   return RemoveDirectory(path)?0:-1;
 #else
-  return rmdir(path);
+  return ::rmdir(path);
 #endif
 }
 
@@ -803,20 +803,20 @@
 
 
 /*!
- *Create an unique temporary file name.  This function doesn't create the
- *file or open it but generates only its name.
+ *Create an unique temporary file name.  This function doesn't create
+ *or open the file but generates only its name.
  *\param tid Caller thread id.
  *\param out Output string.
  */
-void FilesUtility::temporaryFileName(u_long tid, string &out)
+void FilesUtility::temporaryFileName (u_long tid, string &out)
 {
   ostringstream stream;
   static u_long counter = 1;
   counter++;
 
-  if(tmpPath.length() == 0)
-    tmpPath.assign(getdefaultwd(0, 0));
+  if (tmpPath.length () == 0)
+    tmpPath.assign (getdefaultwd (0, 0));
 
   stream << tmpPath << "/myserver_" << counter  << "_" << tid << ".tmp";
-  out.assign(stream.str());
+  out.assign (stream.str ());
 }

Modified: trunk/myserver/src/protocol/ftp/ftp.cpp
===================================================================
--- trunk/myserver/src/protocol/ftp/ftp.cpp     2009-04-28 10:07:49 UTC (rev 
3060)
+++ trunk/myserver/src/protocol/ftp/ftp.cpp     2009-04-28 10:07:55 UTC (rev 
3061)
@@ -2286,7 +2286,7 @@
     ftp_reply(550);
     return;
   }
-  if ( FilesUtility::simpleMakeDirectory(sLocalPath) == 0 )
+  if ( FilesUtility::mkdir (sLocalPath) == 0 )
     ftp_reply(250);
   else
     ftp_reply(501);
@@ -2320,7 +2320,7 @@
     ftp_reply(550);
     return;
   }
-  if ( FilesUtility::deleteDirectory(sLocalPath) == 0 )
+  if ( FilesUtility::rmdir (sLocalPath) == 0 )
     ftp_reply(250);
   else
     ftp_reply(501);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]