Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
not needed now
[simgrid.git] / src / cxx / FileNotFoundException.cxx
1 /*\r
2  * FileNotFoundException.cxx\r
3  *\r
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
5  * All right reserved. \r
6  *\r
7  * This program is free software; you can redistribute \r
8  * it and/or modify it under the terms of the license \r
9  *(GNU LGPL) which comes with this package. \r
10  *\r
11  */\r
12  \r
13  /* FileNotFoundException member functions implementation.\r
14   */  \r
15 \r
16 #include <FileNotFoundException.hpp>\r
17 \r
18 #include <string.h>\r
19 #include <stdlib.h>\r
20 #include <stdio.h>\r
21 \r
22 \r
23 namespace SimGrid\r
24 {\r
25         namespace Msg\r
26         {\r
27                 \r
28                         FileNotFoundException::FileNotFoundException()\r
29                         {\r
30                                 this->reason = (char*) calloc(strlen("File not found") + 1, sizeof(char));\r
31                                 strcpy(this->reason, "File not found");\r
32                         }\r
33                 \r
34                 \r
35                         FileNotFoundException::FileNotFoundException(const FileNotFoundException& rFileNotFoundException)\r
36                         {\r
37                                 const char* reason = rFileNotFoundException.toString();\r
38                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
39                                 strcpy(this->reason, reason);\r
40                                 \r
41                         }\r
42                 \r
43                         FileNotFoundException::FileNotFoundException(const char* file)\r
44                         {\r
45                                 this->reason = (char*) calloc(strlen("File not found ") + strlen(file) + 1, sizeof(char));\r
46                                 sprintf(this->reason, "File not found %s", file);\r
47                         }\r
48                 \r
49                 \r
50                         FileNotFoundException::~FileNotFoundException()\r
51                         {\r
52                                 if(this->reason)\r
53                                         free(this->reason);\r
54                         }\r
55                                 \r
56                         const char* FileNotFoundException::toString(void) const\r
57                         {\r
58                                 return (const char*)(this->reason);     \r
59                         }\r
60                 \r
61                 \r
62                         const FileNotFoundException& FileNotFoundException::operator = (const FileNotFoundException& rFileNotFoundException)\r
63                         {\r
64                                 const char* reason = rFileNotFoundException.toString();\r
65                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
66                                 \r
67                                 return *this;\r
68                         }\r
69                 \r
70         } // namespace Msg      \r
71 \r
72 }// namespace SimGrid\r
73 \r
74 \r
75 \r