MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / Convert

Method Convert

cppcryptfs/dokan/FileNameEnc.cpp:94–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94const WCHAR *FileNameEnc::Convert()
95{
96
97 if (!m_tried) {
98
99 m_KeyDecryptor.Enter();
100
101 m_tried = true;
102
103 try {
104 if (m_con->GetConfig()->m_reverse) {
105 if (rt_is_config_file(m_con, m_plain_path.c_str())) {
106 m_enc_path = m_con->GetConfig()->m_basedir + L"\\";
107 m_enc_path += REVERSE_CONFIG_NAME;
108 } else if (rt_is_virtual_file(m_con, m_plain_path.c_str())) {
109 wstring dirpath;
110 if (!get_file_directory(m_plain_path.c_str(), dirpath))
111 throw(L"virtual reverse get_file_directory failed: " + m_plain_path);
112 if (!decrypt_path(m_con, &dirpath[0], m_enc_path))
113 throw(L"virtual reverse decrypt_path failed: " + dirpath);
114 m_enc_path += L"\\";
115 wstring filename;
116 if (!get_bare_filename(m_plain_path.c_str(), filename))
117 throw(L"virtual reverse get_bare_filename failed: " + m_plain_path);
118 m_enc_path += filename;
119 } else {
120 if (!decrypt_path(m_con, m_plain_path.c_str(), m_enc_path)) {
121 throw(L"reverse decrypt path failed " + m_plain_path);
122 }
123 }
124 } else {
125
126 LPCWSTR plain_path = m_plain_path.c_str();
127 int cache_status = CASE_CACHE_NOTUSED;
128 if (m_con->IsCaseInsensitive()) {
129 cache_status = m_con->m_case_cache.lookup(
130 m_plain_path.c_str(), m_correct_case_path,
131 m_force_case_cache_notfound);
132 if (cache_status == CASE_CACHE_FOUND ||
133 cache_status == CASE_CACHE_NOT_FOUND) {
134 m_file_existed = cache_status == CASE_CACHE_FOUND;
135 plain_path = m_correct_case_path.c_str();
136 } else if (cache_status == CASE_CACHE_MISS) {
137 if (m_con->m_case_cache.load_dir(m_plain_path.c_str())) {
138 cache_status = m_con->m_case_cache.lookup(
139 m_plain_path.c_str(), m_correct_case_path,
140 m_force_case_cache_notfound);
141 if (cache_status == CASE_CACHE_FOUND ||
142 cache_status == CASE_CACHE_NOT_FOUND) {
143 m_file_existed = cache_status == CASE_CACHE_FOUND;
144 plain_path = m_correct_case_path.c_str();
145 }
146 }
147 }
148 wstring stream;
149 wstring file_without_stream;
150 bool have_stream =
151 get_file_stream(plain_path, &file_without_stream, &stream);

Callers

nothing calls this directly

Calls 15

rt_is_config_fileFunction · 0.85
rt_is_virtual_fileFunction · 0.85
get_file_directoryFunction · 0.85
decrypt_pathFunction · 0.85
get_bare_filenameFunction · 0.85
get_file_streamFunction · 0.85
remove_stream_typeFunction · 0.85
touppercaseFunction · 0.85
DbgPrintFunction · 0.85
encrypt_pathFunction · 0.85
GetConfigMethod · 0.80
IsCaseInsensitiveMethod · 0.80

Tested by

no test coverage detected