Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use pointers instead references.
[simgrid.git] / src / cxx / Environment.cxx
index a44fd2a..71e0acf 100644 (file)
@@ -1,8 +1,27 @@
+/*\r
+ * Environment.cxx\r
+ *\r
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
+ * All right reserved. \r
+ *\r
+ * This program is free software; you can redistribute \r
+ * it and/or modify it under the terms of the license \r
+ *(GNU LGPL) which comes with this package. \r
+ *\r
+ */\r
\r
+ /* Environment member functions implementation.\r
+  */  \r
+  \r
 #include <Environment.hpp>\r
 \r
+#include <stdlib.h>\r
+\r
 #include <sys/types.h>\r
 #include <sys/stat.h>\r
 \r
+#include <msg/msg.h>\r
+\r
 #ifndef S_ISREG\r
        #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)\r
 #endif\r
@@ -17,14 +36,14 @@ namespace SimGrid
                        this->loaded = false;\r
                }\r
                                \r
-               Environment::Environment(const Environment& rEnvironment);\r
+               Environment::Environment(const Environment& rEnvironment)\r
                {\r
                        this->file = rEnvironment.getFile();\r
                        this->loaded = rEnvironment.isLoaded();\r
                }\r
                \r
                Environment::Environment(const char* file)\r
-               throw(NullPointerException, InvalidArgumentException);\r
+               throw(NullPointerException, FileNotFoundException)\r
                {\r
                        // check parameters\r
                        \r
@@ -33,8 +52,8 @@ namespace SimGrid
                        \r
                        struct stat statBuf = {0};\r
                                \r
-                       if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
-                               throw InvalidParameterException("file (file not found)");\r
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
+                               throw FileNotFoundException("file (file not found)");\r
                                \r
                        this->file = file;\r
                        this->loaded = false;\r
@@ -79,7 +98,7 @@ namespace SimGrid
                        \r
                        struct stat statBuf = {0};\r
                                \r
-                       if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
                                throw FileNotFoundException(file);\r
                                        \r
                        MSG_create_environment(file);\r
@@ -109,7 +128,7 @@ namespace SimGrid
                        \r
                        struct stat statBuf = {0};\r
                                \r
-                       if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
                                throw FileNotFoundException("file (file not found)");\r
                                \r
                        this->file = file;\r
@@ -136,4 +155,5 @@ namespace SimGrid
                }\r
                                \r
        } // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r