#include "DCPS/DdsDcps_pch.h"
#include "FileSystemStorage.h"
#include "ace/Dirent.h"
#include "ace/Vector_T.h"
#include "ace/OS_NS_sys_stat.h"
#include "ace/OS_NS_macros.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_stdio.h"
#include <cstdio>
#include <cstring>
#include <stdexcept>
#include <fstream>
Include dependency graph for FileSystemStorage.cpp:
Go to the source code of this file.
Namespaces | |
namespace | OpenDDS |
namespace | OpenDDS::FileSystemStorage |
Typedefs | |
typedef size_t | String_Index_t |
Functions | |
void | add_slash (ACE_TString &str) |
bool | increment (ACE_TString &logical) |
int | dds_mkdir (const ACE_TCHAR *path) |
int | dds_chdir (const ACE_TCHAR *path) |
bool | is_dir (const ACE_TCHAR *path) |
int | dds_rmdir (const ACE_TCHAR *path) |
ACE_TString | overflow_dir_name (unsigned int n) |
void | recursive_remove (const ACE_TString &dirname) |
ACE_TString | OpenDDS::FileSystemStorage::b32h_encode (const ACE_TCHAR *decoded) |
ACE_TString | OpenDDS::FileSystemStorage::b32h_decode (const ACE_TCHAR *encoded) |
Variables | |
const size_t | FSS_MAX_FILE_NAME = 150 |
const size_t | FSS_MAX_FILE_NAME_ENCODED = 240 |
const size_t | FSS_MAX_OVERFLOW_DIR = 9999 |
const ACE_TCHAR | FSS_DEFAULT_FILE_NAME [] = ACE_TEXT("F00000000000000") |
const ACE_TCHAR | FSS_DEFAULT_DIR_NAME [] = ACE_TEXT("D00000000000000") |
ACE_TString | cwd_ |
typedef size_t String_Index_t |
Definition at line 26 of file FileSystemStorage.cpp.
void @6::add_slash | ( | ACE_TString & | str | ) | [static] |
Definition at line 35 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::Directory(), and OpenDDS::FileSystemStorage::Directory::scan_dir().
00036 { 00037 if (str.length() == 0) return; 00038 00039 if (str[str.length() - 1] == ACE_TEXT('\\')) { 00040 str[str.length() - 1] = ACE_TEXT('/'); 00041 00042 } else if (str[str.length() - 1] != ACE_TEXT('/')) { 00043 str += ACE_TEXT('/'); 00044 } 00045 }
int @6::dds_chdir | ( | const ACE_TCHAR * | path | ) | [inline, static] |
Definition at line 158 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::make_new_subdir().
int @6::dds_mkdir | ( | const ACE_TCHAR * | path | ) | [inline, static] |
Definition at line 153 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::add_entry(), OpenDDS::FileSystemStorage::Directory::Directory(), and OpenDDS::FileSystemStorage::Directory::make_new_subdir().
int @6::dds_rmdir | ( | const ACE_TCHAR * | path | ) | [inline, static] |
Definition at line 169 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::make_new_subdir(), recursive_remove(), and OpenDDS::FileSystemStorage::Directory::removing().
bool @6::increment | ( | ACE_TString & | logical | ) | [static] |
Definition at line 48 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::create_next_dir(), and OpenDDS::FileSystemStorage::Directory::create_next_file().
00049 { 00050 for (size_t i = logical.length() - 1; i >= 1; --i) { 00051 //we could use the entire range of 255 values but we'll keep 00052 //these names to 7-bit ASCII 00053 if (logical[i] < 0x7F) { 00054 ++logical[i]; 00055 return true; 00056 } 00057 } 00058 00059 return false; 00060 }
bool @6::is_dir | ( | const ACE_TCHAR * | path | ) | [inline, static] |
Definition at line 163 of file FileSystemStorage.cpp.
Referenced by recursive_remove(), and OpenDDS::FileSystemStorage::Directory::scan_dir().
00164 { 00165 ACE_stat st; 00166 return ACE_OS::stat(path, &st) != -1 && (st.st_mode & S_IFDIR); 00167 }
ACE_TString @6::overflow_dir_name | ( | unsigned int | n | ) | [static] |
Definition at line 176 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::add_entry().
00177 { 00178 ACE_TString of_name = ACE_TEXT("_overflow. /"); 00179 ACE_TCHAR* buf = &of_name[10]; 00180 ACE_OS::snprintf(buf, 5, ACE_TEXT("%04u"), n); 00181 of_name[14] = L'/'; // snprintf has clobbered / with a null 00182 return of_name; 00183 }
void @6::recursive_remove | ( | const ACE_TString & | dirname | ) | [static] |
Definition at line 209 of file FileSystemStorage.cpp.
References DDS_DIRENT, DDS_Dirent, dds_rmdir(), and is_dir().
Referenced by OpenDDS::FileSystemStorage::Directory::remove().
00210 { 00211 using namespace OpenDDS::FileSystemStorage; 00212 DDS_Dirent dir(dirname.c_str()); 00213 { 00214 CwdGuard cg(dirname); 00215 00216 for (DDS_DIRENT* ent = dir.read(); ent; ent = dir.read()) { 00217 if (ent->d_name[0] == ACE_TEXT('.') && (!ent->d_name[1] || 00218 (ent->d_name[1] == ACE_TEXT('.') && !ent->d_name[2]))) { 00219 continue; // skip '.' and '..' 00220 } 00221 00222 if (is_dir(ent->d_name)) { 00223 recursive_remove(ent->d_name); 00224 00225 } else { // regular file 00226 ACE_OS::unlink(ent->d_name); 00227 } 00228 } 00229 } 00230 dds_rmdir(dirname.c_str()); 00231 }
ACE_TString cwd_ |
Definition at line 186 of file FileSystemStorage.cpp.
const ACE_TCHAR FSS_DEFAULT_DIR_NAME[] = ACE_TEXT("D00000000000000") [static] |
Definition at line 33 of file FileSystemStorage.cpp.
const ACE_TCHAR FSS_DEFAULT_FILE_NAME[] = ACE_TEXT("F00000000000000") [static] |
Definition at line 32 of file FileSystemStorage.cpp.
const size_t FSS_MAX_FILE_NAME = 150 [static] |
Definition at line 30 of file FileSystemStorage.cpp.
const size_t FSS_MAX_FILE_NAME_ENCODED = 240 [static] |
Definition at line 30 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::scan_dir().
const size_t FSS_MAX_OVERFLOW_DIR = 9999 [static] |
Definition at line 31 of file FileSystemStorage.cpp.
Referenced by OpenDDS::FileSystemStorage::Directory::add_entry().