myserver-commit
[Top][All Lists]
Advanced

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

[myserver-commit] [2826] The `temporaryFileName' function was moved from


From: Giuseppe Scrivano
Subject: [myserver-commit] [2826] The `temporaryFileName' function was moved from the class `Server' to the class `FilesUtility'.
Date: Fri, 19 Sep 2008 22:22:03 +0000

Revision: 2826
          http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2826
Author:   gscrivano
Date:     2008-09-19 22:22:02 +0000 (Fri, 19 Sep 2008)

Log Message:
-----------
The `temporaryFileName' function was moved from the class `Server' to the class 
`FilesUtility'.

Modified Paths:
--------------
    trunk/myserver/include/base/file/files_utility.h
    trunk/myserver/include/server/server.h
    trunk/myserver/src/base/file/files_utility.cpp
    trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
    trunk/myserver/src/protocol/http/http.cpp
    trunk/myserver/src/server/server.cpp

Modified: trunk/myserver/include/base/file/files_utility.h
===================================================================
--- trunk/myserver/include/base/file/files_utility.h    2008-09-18 22:14:31 UTC 
(rev 2825)
+++ trunk/myserver/include/base/file/files_utility.h    2008-09-19 22:22:02 UTC 
(rev 2826)
@@ -1,7 +1,7 @@
 /* -*- mode: c++ -*- */
 /*
 MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 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
@@ -28,77 +28,81 @@
 
 class FilesUtility
 {
-       FileHandle handle;
-       string filename;
+private:
+  /*! Don't allow instances for this class.  */
+  FilesUtility();
 
-private:
-       /*! Don't allow instances for this class.  */
-       FilesUtility();
 public:
-       static int getPathRecursionLevel(const char*);
+  static int getPathRecursionLevel(const char*);
   static int getPathRecursionLevel(string& filename)
-    {return getPathRecursionLevel(filename.c_str()); }
+  {return getPathRecursionLevel(filename.c_str()); }
 
-       static time_t getLastModTime(const char *filename);
-       static time_t getLastModTime(string const &filename)
+  static time_t getLastModTime(const char *filename);
+  static time_t getLastModTime(string const &filename)
     {return getLastModTime(filename.c_str());}
 
-       static time_t getCreationTime(const char *filename);
-       static time_t getCreationTime(string const &filename)
+  static time_t getCreationTime(const char *filename);
+  static time_t getCreationTime(string const &filename)
     {return getCreationTime(filename.c_str());}
 
-       static time_t getLastAccTime(const char *filename);
-       static time_t getLastAccTime(string const &filename)
+  static time_t getLastAccTime(const char *filename);
+  static time_t getLastAccTime(string const &filename)
     {return getLastAccTime(filename.c_str());}
 
   static int chown(const char* filename, int uid, int gid);
   static int chown(string const &filename, int uid, int gid)
     {return chown(filename.c_str(), uid, gid);}
 
-       static int completePath(char**, int *size, int dontRealloc=0);
+  static int completePath(char**, int *size, int dontRealloc=0);
   static int completePath(string &fileName);
 
-       static int isDirectory(const char*);
+  static int isDirectory(const char*);
   static int isDirectory(string& dir){return isDirectory(dir.c_str());}
 
-       static int isLink(const char*);
+  static int isLink(const char*);
   static int isLink(string& dir){return isLink(dir.c_str());}
 
   static int getShortFileName(char*,char*,int);
 
-       static int fileExists(const char * );
-       static int fileExists(string const &file)
+  static int fileExists(const char * );
+  static int fileExists(string const &file)
     {return fileExists(file.c_str());}
 
-       static int deleteFile(const char * );
-       static int deleteFile(string const &file)
+  static int deleteFile(const char * );
+  static int deleteFile(string const &file)
     {return deleteFile(file.c_str());}
 
     static int renameFile(const char*, const char*);
-       static int renameFile(string const &before, string const &after)
+  static int renameFile(string const &before, string const &after)
     {return renameFile(before.c_str(), after.c_str());}
 
-       static int copyFile(const char*, const char*, int overwrite);
-       static int copyFile(File, File);
-       static int copyFile(string const &src, string const &dest, int 
overwrite)
-       {return copyFile(src.c_str(), dest.c_str(), overwrite);}
+  static int copyFile(const char*, const char*, int overwrite);
+  static int copyFile(File, File);
+  static int copyFile(string const &src, string const &dest, int overwrite)
+  {return copyFile(src.c_str(), dest.c_str(), overwrite);}
 
-       static void getFileExt(char* ext,const char* filename);
-       static void getFileExt(string& ext, string const &filename);
+  static void getFileExt(char* ext,const char* filename);
+  static void getFileExt(string& ext, string const &filename);
 
   static void splitPathLength(const char *path, int *dir, int *filename);
-       static void splitPath(const char* path, char* dir, char*filename);
-       static void splitPath(string const &path, string& dir, string& 
filename);
+  static void splitPath(const char* path, char* dir, char*filename);
+  static void splitPath(string const &path, string& dir, string& filename);
 
   static int getFilenameLength(const char*, int *);
-       static void getFilename(const char* path, char* filename);
-       static void getFilename(string const &path, string& filename);
+  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 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 void temporaryFileName(u_long tid, string &out);
+
+  static void setTmpPath(string & path){tmpPath.assign(path);}
+private:
+       static string tmpPath;
 };
 #endif

Modified: trunk/myserver/include/server/server.h
===================================================================
--- trunk/myserver/include/server/server.h      2008-09-18 22:14:31 UTC (rev 
2825)
+++ trunk/myserver/include/server/server.h      2008-09-19 22:22:02 UTC (rev 
2826)
@@ -140,7 +140,6 @@
        u_long getBuffersize();
        u_long getBuffersize2();
   u_long getThrottlingRate();
-       void temporaryFileName(u_long tid, string &out);
        int waitNewConnection(u_long tid, u_long timeout);
        XmlParser *getConfiguration(){return &configurationFileManager;}
        ListenThreads *getListenThreads(){return &listenThreads;}
@@ -248,7 +247,6 @@
        string* mainConfigurationFile;
        string* vhostConfigurationFile;
        string* mimeConfigurationFile;
-       string tmpPath;
        PluginsManager pluginsManager;
        GenericPluginsManager genericPluginsManager;
        ProcessServerManager processServerManager;

Modified: trunk/myserver/src/base/file/files_utility.cpp
===================================================================
--- trunk/myserver/src/base/file/files_utility.cpp      2008-09-18 22:14:31 UTC 
(rev 2825)
+++ trunk/myserver/src/base/file/files_utility.cpp      2008-09-19 22:22:02 UTC 
(rev 2826)
@@ -17,9 +17,9 @@
 
 
 #include "stdafx.h"
+#include <include/base/file/files_utility.h>
 #include <include/base/utility.h>
 #include <include/base/string/stringutils.h>
-#include <include/base/file/files_utility.h>
 
 #ifdef NOT_WIN
 extern "C" {
@@ -43,6 +43,8 @@
 
 using namespace std;
 
+string FilesUtility::tmpPath;
+
 /*!
  *Constructor body.
  */
@@ -780,3 +782,22 @@
   return rmdir(path);
 #endif
 }
+
+
+/*!
+ *Create an unique temporary file name.  This function doesn't create the
+ *file or open it but generates only its name.
+ *\param
+ */
+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));
+
+  stream << tmpPath << "/tmp_" << counter  << "_" << tid;
+  out.assign(stream.str());
+}

Modified: trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp
===================================================================
--- trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp 2008-09-18 22:14:31 UTC 
(rev 2825)
+++ trunk/myserver/src/http_handler/fastcgi/fastcgi.cpp 2008-09-19 22:22:02 UTC 
(rev 2826)
@@ -387,7 +387,7 @@
 
   initialTicks = getTicks();
 
-  Server::getInstance()->temporaryFileName(td->id, outDataPath);
+  FilesUtility::temporaryFileName(td->id, outDataPath);
 
   if(con.tempOut.createTemporaryFile(outDataPath.c_str()))
   {

Modified: trunk/myserver/src/protocol/http/http.cpp
===================================================================
--- trunk/myserver/src/protocol/http/http.cpp   2008-09-18 22:14:31 UTC (rev 
2825)
+++ trunk/myserver/src/protocol/http/http.cpp   2008-09-19 22:22:02 UTC (rev 
2826)
@@ -1495,8 +1495,8 @@
      *For methods that accept data after the HTTP header set the correct
      *pointer and create a file containing the informations after the header.
      */
-    Server::getInstance()->temporaryFileName(td->id, td->inputDataPath);
-    Server::getInstance()->temporaryFileName(td->id, td->outputDataPath);
+    FilesUtility::temporaryFileName(td->id, td->inputDataPath);
+    FilesUtility::temporaryFileName(td->id, td->outputDataPath);
 
     dynamicCommand = staticHttp.dynCmdManager.getPlugin(td->request.cmd);
 

Modified: trunk/myserver/src/server/server.cpp
===================================================================
--- trunk/myserver/src/server/server.cpp        2008-09-18 22:14:31 UTC (rev 
2825)
+++ trunk/myserver/src/server/server.cpp        2008-09-19 22:22:02 UTC (rev 
2826)
@@ -38,7 +38,6 @@
 extern "C"
 {
 #ifdef WIN32
-  //#include <Ws2tcpip.h>
 #include <direct.h>
 #endif
 #ifdef NOT_WIN
@@ -1014,13 +1013,10 @@
   data = configurationFileManager.getValue("TEMP_DIRECTORY");
   if(data)
   {
-    tmpPath.assign(data);
+    string tmpPath(data);
     FilesUtility::completePath(tmpPath);
+    FilesUtility::setTmpPath(tmpPath);
   }
-  else
-  {
-    tmpPath.assign(getdefaultwd(0, 0));
-  }
 
   data = configurationFileManager.getValue("MAX_FILESCACHE_FILESIZE");
   if(data)
@@ -1272,9 +1268,9 @@
   newConnection->setLocalPort(localPort);
   newConnection->setIpAddr(ipAddr);
   newConnection->setLocalIpAddr(localIpAddr);
-  newConnection->host = Server::getInstance()->vhostList->getVHost(0,
-                                                             localIpAddr,
-                                                             localPort);
+  newConnection->host = vhostList->getVHost(0,
+                                            localIpAddr,
+                                            localPort);
 
   /* No vhost for the connection so bail.  */
   if(newConnection->host == 0)
@@ -1283,7 +1279,7 @@
     return 0;
   }
 
-  protocol = 
Server::getInstance()->getProtocol(newConnection->host->getProtocolName());
+  protocol = getProtocol(newConnection->host->getProtocolName());
 
   if(protocol)
     opts = protocol->getProtocolOptions();
@@ -2284,20 +2280,6 @@
 }
 
 /*!
- *Create an unique temporary file name.  This function doesn't create the
- *file or open it but generates only its name.
- *\param
- */
-void Server::temporaryFileName(u_long tid, string &out)
-{
-  ostringstream stream;
-  static u_long counter = 1;
-  counter++;
-  stream << tmpPath << "/tmp_" << counter  << "_" << tid;
-  out.assign(stream.str());
-}
-
-/*!
  *Prepare the log to print an error.
  */
 int Server::logPreparePrintError()






reply via email to

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