aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/include/file_io_utils.h
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2017-04-25 15:03:38 -0400
committerLee Clagett <code@leeclagett.com>2017-04-25 16:07:32 -0400
commit7199fc8373faab6f6608e79658674d5fba0ca3cc (patch)
tree1755976e2cc5b2ce04ac718a06b68b077385f173 /contrib/epee/include/file_io_utils.h
parentMerge pull request #1996 (diff)
downloadmonero-7199fc8373faab6f6608e79658674d5fba0ca3cc.tar.xz
Removed some unused epee functions
Diffstat (limited to '')
-rw-r--r--contrib/epee/include/file_io_utils.h317
1 files changed, 0 insertions, 317 deletions
diff --git a/contrib/epee/include/file_io_utils.h b/contrib/epee/include/file_io_utils.h
index 7e8521838..c387743a6 100644
--- a/contrib/epee/include/file_io_utils.h
+++ b/contrib/epee/include/file_io_utils.h
@@ -28,197 +28,13 @@
#ifndef _FILE_IO_UTILS_H_
#define _FILE_IO_UTILS_H_
-
-//#include <sys/types.h>
-//#include <sys/stat.h>
-
#include <iostream>
#include <boost/filesystem.hpp>
-
-#ifndef MAKE64
- #define MAKE64(low,high) ((__int64)(((DWORD)(low)) | ((__int64)((DWORD)(high))) << 32))
-#endif
-
-#ifdef WINDOWS_PLATFORM
-#include <psapi.h>
-#include <strsafe.h>
-#include <string.h>
-#include <mbstring.h>
-
-#endif
-
-
-
namespace epee
{
namespace file_io_utils
{
-#ifdef WINDOWS_PLATFORM
-
- inline
- std::string get_temp_file_name_a()
- {
- std::string str_result;
- char sz_temp[MAX_PATH*2] = {0};
- if(!::GetTempPathA( sizeof( sz_temp ), sz_temp ))
- return str_result;
-
- char sz_temp_file[MAX_PATH*2] = {0};
- if(!::GetTempFileNameA( sz_temp, "mail", 0, sz_temp_file))
- return str_result;
- sz_temp_file[sizeof(sz_temp_file)-1] = 0; //be happy!
- str_result = sz_temp_file;
- return str_result;
- }
-
-
-#ifdef BOOST_LEXICAL_CAST_INCLUDED
- inline
- bool get_not_used_filename(const std::string& folder, OUT std::string& result_name)
- {
- DWORD folder_attr = ::GetFileAttributesA(folder.c_str());
- if(folder_attr == INVALID_FILE_ATTRIBUTES)
- return false;
- if(!(folder_attr&FILE_ATTRIBUTE_DIRECTORY))
- return false;
-
-
- std::string base_name = folder + "\\tmp";
- std::string tmp_name;
- bool name_found = false;
- int current_index = 0;
- tmp_name = base_name + boost::lexical_cast<std::string>(current_index) + ".tmp";
- while(!name_found)
- {
- if(INVALID_FILE_ATTRIBUTES == ::GetFileAttributesA(tmp_name.c_str()))
- name_found = true;
- else
- {
- current_index++;
- tmp_name = base_name + boost::lexical_cast<std::string>(current_index) + ".tmp";
- }
- }
- result_name = tmp_name;
- return true;
- }
-#endif
-
- inline
- std::string get_temp_folder_a()
- {
- std::string str_result;
- char sz_temp[MAX_PATH*2] = {0};
- if(!::GetTempPathA( sizeof( sz_temp ), sz_temp ))
- return str_result;
- sz_temp[(sizeof(sz_temp)/sizeof(sz_temp[0])) -1] = 0;
- str_result = sz_temp;
- return str_result;
- }
-
- std::string convert_from_device_path_to_standart(const std::string& path)
- {
-
-
- STRSAFE_LPSTR pszFilename = (STRSAFE_LPSTR)path.c_str();
-
- // Translate path with device name to drive letters.
- char szTemp[4000] = {0};
-
- if (::GetLogicalDriveStringsA(sizeof(szTemp)-1, szTemp))
- {
- char szName[MAX_PATH];
- char szDrive[3] = " :";
- BOOL bFound = FALSE;
- char* p = szTemp;
-
- do
- {
- // Copy the drive letter to the template string
- *szDrive = *p;
-
- // Look up each device name
- if (::QueryDosDeviceA(szDrive, szName, sizeof(szName)))
- {
- UINT uNameLen = strlen(szName);
-
- if (uNameLen < MAX_PATH)
- {
- bFound = _mbsnbicmp((const unsigned char*)pszFilename, (const unsigned char*)szName,
- uNameLen) == 0;
-
- if (bFound)
- {
- // Reconstruct pszFilename using szTempFile
- // Replace device path with DOS path
- char szTempFile[MAX_PATH] = {0};
- StringCchPrintfA(szTempFile,
- MAX_PATH,
- "%s%s",
- szDrive,
- pszFilename+uNameLen);
- return szTempFile;
- //::StringCchCopyNA(pszFilename, MAX_PATH+1, szTempFile, strlen(szTempFile));
- }
- }
- }
-
- // Go to the next NULL character.
- while (*p++);
- } while (!bFound && *p); // end of string
- }
-
- return "";
- }
-
- inline
- std::string get_process_path_by_pid(DWORD pid)
- {
- std::string res;
-
- HANDLE hprocess = 0;
- if( hprocess = ::OpenProcess( PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, pid) )
- {
- char buff[MAX_PATH]= {0};
- if(!::GetModuleFileNameExA( hprocess, 0, buff, MAX_PATH - 1 ))
- res = "Unknown_b";
- else
- {
- buff[MAX_PATH - 1]=0; //be happy!
- res = buff;
- std::string::size_type a = res.rfind( '\\' );
- if ( a != std::string::npos )
- res.erase( 0, a+1);
-
- }
- ::CloseHandle( hprocess );
- }else
- res = "Unknown_a";
-
- return res;
- }
-
-
-
-
-
- inline
- std::wstring get_temp_file_name_w()
- {
- std::wstring str_result;
- wchar_t sz_temp[MAX_PATH*2] = {0};
- if(!::GetTempPathW( sizeof(sz_temp)/sizeof(sz_temp[0]), sz_temp ))
- return str_result;
-
- wchar_t sz_temp_file[MAX_PATH+1] = {0};
- if(!::GetTempFileNameW( sz_temp, L"mail", 0, sz_temp_file))
- return str_result;
-
- sz_temp_file[(sizeof(sz_temp_file)/sizeof(sz_temp_file[0]))-1] = 0; //be happy!
- str_result = sz_temp_file;
- return str_result;
- }
-#endif
inline
bool is_file_exist(const std::string& path)
{
@@ -226,35 +42,6 @@ namespace file_io_utils
return boost::filesystem::exists(p);
}
- /*
- inline
- bool save_string_to_handle(HANDLE hfile, const std::string& str)
- {
-
-
-
- if( INVALID_HANDLE_VALUE != hfile )
- {
- DWORD dw;
- if( !::WriteFile( hfile, str.data(), (DWORD) str.size(), &dw, NULL) )
- {
- int err_code = GetLastError();
- //LOG_PRINT("Failed to write to file handle: " << hfile<< " Last error code:" << err_code << " : " << log_space::get_win32_err_descr(err_code), LOG_LEVEL_2);
- return false;
- }
- ::CloseHandle(hfile);
- return true;
- }else
- {
- //LOG_WIN32_ERROR(::GetLastError());
- return false;
- }
-
- return false;
- }*/
-
-
-
inline
bool save_string_to_file(const std::string& path_to_file, const std::string& str)
{
@@ -275,32 +62,6 @@ namespace file_io_utils
}
}
- /*
- inline
- bool load_form_handle(HANDLE hfile, std::string& str)
- {
- if( INVALID_HANDLE_VALUE != hfile )
- {
- bool res = true;
- DWORD dw = 0;
- DWORD fsize = ::GetFileSize(hfile, &dw);
- if(fsize > 300000000)
- {
- ::CloseHandle(hfile);
- return false;
- }
- if(fsize)
- {
- str.resize(fsize);
- if(!::ReadFile( hfile, (LPVOID)str.data(), (DWORD)str.size(), &dw, NULL))
- res = false;
- }
- ::CloseHandle(hfile);
- return res;
- }
- return false;
- }
- */
inline
bool get_file_time(const std::string& path_to_file, OUT time_t& ft)
{
@@ -371,84 +132,6 @@ namespace file_io_utils
return false;
}
}
-
- /*
- bool remove_dir_and_subirs(const char* path_to_dir);
-
- inline
- bool clean_dir(const char* path_to_dir)
- {
- if(!path_to_dir)
- return false;
-
- std::string folder = path_to_dir;
- WIN32_FIND_DATAA find_data = {0};
- HANDLE hfind = ::FindFirstFileA((folder + "\\*.*").c_str(), &find_data);
- if(INVALID_HANDLE_VALUE == hfind)
- return false;
- do{
- if(!strcmp("..", find_data.cFileName) || (!strcmp(".", find_data.cFileName)))
- continue;
-
- if(find_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
- {
- if(!remove_dir_and_subirs((folder + "\\" + find_data.cFileName).c_str()))
- return false;
- }else
- {
- if(!::DeleteFileA((folder + "\\" + find_data.cFileName).c_str()))
- return false;
- }
-
-
- }while(::FindNextFileA(hfind, &find_data));
- ::FindClose(hfind);
-
- return true;
- }
- */
-#ifdef WINDOWS_PLATFORM
- inline bool get_folder_content(const std::string& path, std::list<WIN32_FIND_DATAA>& OUT target_list)
- {
- WIN32_FIND_DATAA find_data = {0};
- HANDLE hfind = ::FindFirstFileA((path + "\\*.*").c_str(), &find_data);
- if(INVALID_HANDLE_VALUE == hfind)
- return false;
- do{
- if(!strcmp("..", find_data.cFileName) || (!strcmp(".", find_data.cFileName)))
- continue;
-
- target_list.push_back(find_data);
-
- }while(::FindNextFileA(hfind, &find_data));
- ::FindClose(hfind);
-
- return true;
- }
-#endif
- inline bool get_folder_content(const std::string& path, std::list<std::string>& OUT target_list, bool only_files = false)
- {
- try
- {
-
- boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
- for ( boost::filesystem::directory_iterator itr( path ); itr != end_itr; ++itr )
- {
- if ( only_files && boost::filesystem::is_directory(itr->status()) )
- {
- continue;
- }
- target_list.push_back(itr->path().filename().string());
- }
-
- }
-
- catch(...)
- {
- return false;
- }
- return true;
- }
}
}