1 #include "ace/FILE_Connector.h"
2 #include "ace/OS_NS_unistd.h"
4 #include "JAWS/Filecache.h"
5 #include "JAWS/Cache_List_T.h"
8 JAWS_Referenced_Filecache_Factory::destroy (JAWS_Cache_Object
*object
)
10 JAWS_FILE
*file
= (JAWS_FILE
*) object
->data ();
13 file
->map ()->close ();
15 this->JAWS_Referenced_Cache_Object_Factory::destroy (object
);
19 JAWS_Counted_Filecache_Factory::destroy (JAWS_Cache_Object
*object
)
21 JAWS_FILE
*file
= (JAWS_FILE
*) object
->data ();
24 file
->map ()->close ();
26 this->JAWS_Counted_Cache_Object_Factory::destroy (object
);
29 JAWS_Cached_FILE::JAWS_Cached_FILE (const char *const &filename
,
30 JAWS_Filecache_Proxy::Cache_Manager
*cm
)
31 : JAWS_Filecache_Proxy (filename
, cm
)
33 ACE_HANDLE handle
= ACE_INVALID_HANDLE
;
35 if (this->data () != 0)
37 handle
= ACE_OS::dup (this->data ()->get_handle ());
41 JAWS_FILE
*file
= new JAWS_FILE
;
42 ACE_FILE_Connector file_connector
;
44 int result
= file_connector
.connect (*file
, ACE_FILE_Addr (filename
));
45 if (result
== -1 || file
->get_handle () == ACE_INVALID_HANDLE
)
47 // TODO: do something here!
51 file
->get_info (info
);
53 handle
= ACE_OS::dup (file
->get_handle ());
56 JAWS_Cached_FILE
cf (filename
, file
, info
.size_
, cm
);
59 new (this) JAWS_Cached_FILE (filename
, cm
);
65 this->file_
.set_handle (handle
);
68 JAWS_Cached_FILE::JAWS_Cached_FILE (const char *const &filename
,
71 JAWS_Filecache_Proxy::Cache_Manager
*cm
)
72 : JAWS_Filecache_Proxy (filename
, file
, size
, cm
)
76 JAWS_Cached_FILE::~JAWS_Cached_FILE ()
82 JAWS_Cached_FILE::file ()
84 return &(this->file_
);
88 JAWS_Cached_FILE::mmap ()
90 return (this->data () == 0 ? 0 : this->data ()->mem_map ());