Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
d99519058fbd1123d6320af019c7643e5d539bef
[simgrid.git] / src / cxx / FileNotFoundException.cxx
1 #include <FileNotFoundException.hpp>\r
2 \r
3 #include <string.h>\r
4 #include <stdlib.h>\r
5 #include <stdio.h>\r
6 \r
7 \r
8 namespace SimGrid\r
9 {\r
10         namespace Msg\r
11         {\r
12                 \r
13                         FileNotFoundException::FileNotFoundException()\r
14                         {\r
15                                 this->reason = (char*) calloc(strlen("File not found") + 1, sizeof(char));\r
16                                 strcpy(this->reason, "File not found");\r
17                         }\r
18                 \r
19                 \r
20                         FileNotFoundException::FileNotFoundException(const FileNotFoundException& rFileNotFoundException)\r
21                         {\r
22                                 const char* reason = rFileNotFoundException.toString();\r
23                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
24                                 strcpy(this->reason, reason);\r
25                                 \r
26                         }\r
27                 \r
28                         FileNotFoundException::FileNotFoundException(const char* file)\r
29                         {\r
30                                 this->reason = (char*) calloc(strlen("File not found ") + strlen(file) + 1, sizeof(char));\r
31                                 sprintf(this->reason, "File not found %s", file);\r
32                         }\r
33                 \r
34                 \r
35                         FileNotFoundException::~FileNotFoundException()\r
36                         {\r
37                                 if(this->reason)\r
38                                         free(this->reason);\r
39                         }\r
40                                 \r
41                         const char* FileNotFoundException::toString(void) const\r
42                         {\r
43                                 return (const char*)(this->reason);     \r
44                         }\r
45                 \r
46                 \r
47                         const FileNotFoundException& FileNotFoundException::operator = (const FileNotFoundException& rFileNotFoundException)\r
48                         {\r
49                                 const char* reason = rFileNotFoundException.toString();\r
50                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
51                                 \r
52                                 return *this;\r
53                         }\r
54                 \r
55         } // namespace Msg      \r
56 \r
57 }// namespace SimGrid\r
58 \r
59 \r
60 \r