Logo AND Algorithmique Numérique Distribuée

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