Skip to content

Commit

Permalink
Fix build errors on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed May 12, 2024
1 parent b59584d commit eb9a385
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions filter/url.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ void filter_url_unlink (std::string filename)
void filter_url_rename (const std::string& oldfilename, const std::string& newfilename)
{
#ifdef HAVE_WINDOWS
wstring woldfilename = filter::strings::string2wstring (oldfilename);
wstring wnewfilename = filter::strings::string2wstring (newfilename);
std::wstring woldfilename = filter::strings::string2wstring (oldfilename);
std::wstring wnewfilename = filter::strings::string2wstring (newfilename);
_wrename (woldfilename.c_str (), wnewfilename.c_str ());
#else
rename (oldfilename.c_str (), newfilename.c_str ());
Expand Down Expand Up @@ -470,7 +470,7 @@ bool file_or_dir_exists (std::string url)
{
#ifdef HAVE_WINDOWS
// Function '_wstat' works with wide characters.
wstring wurl = filter::strings::string2wstring(url);
std::wstring wurl = filter::strings::string2wstring(url);
struct _stat buffer;
int result = _wstat (wurl.c_str (), &buffer);
return (result == 0);
Expand Down Expand Up @@ -498,7 +498,7 @@ void filter_url_mkdir (std::string directory)
{
int status;
#ifdef HAVE_WINDOWS
wstring wdirectory = filter::strings::string2wstring(directory);
std::wstring wdirectory = filter::strings::string2wstring(directory);
status = _wmkdir (wdirectory.c_str());
#else
status = mkdir (directory.c_str(), 0777);
Expand All @@ -514,7 +514,7 @@ void filter_url_mkdir (std::string directory)
reverse (paths.begin (), paths.end ());
for (unsigned int i = 0; i < paths.size (); i++) {
#ifdef HAVE_WINDOWS
wstring wpathsi = filter::strings::string2wstring(paths[i]);
std::wstring wpathsi = filter::strings::string2wstring(paths[i]);
_wmkdir (wpathsi.c_str ());
#else
mkdir (paths[i].c_str (), 0777);
Expand Down Expand Up @@ -546,18 +546,18 @@ void filter_url_rmdir (std::string directory)
filter_url_rmdir(path);
}
#ifdef HAVE_WINDOWS
// Remove directory.
wstring wpath = filter::strings::string2wstring(path);
_wrmdir(wpath.c_str());
// Remove file.
filter_url_unlink(path);
// Remove directory.
std::wstring wpath = filter::strings::string2wstring(path);
_wrmdir(wpath.c_str());
// Remove file.
filter_url_unlink(path);
#else
// On Linux remove the directory or the file.
// On Linux remove the directory or the file.
remove(path.c_str());
#endif
}
#ifdef HAVE_WINDOWS
wstring wdirectory = filter::strings::string2wstring(directory);
std::wstring wdirectory = filter::strings::string2wstring(directory);
_wrmdir(wdirectory.c_str());
filter_url_unlink(directory);
#else
Expand All @@ -582,7 +582,7 @@ bool filter_url_is_dir (std::string path)
{
#ifdef HAVE_WINDOWS
// Function '_wstat', on Windows, works with wide characters.
wstring wpath = filter::strings::string2wstring (path);
std::wstring wpath = filter::strings::string2wstring (path);
struct _stat sb;
_wstat (wpath.c_str (), &sb);
#else
Expand All @@ -609,7 +609,7 @@ bool filter_url_is_dir (std::string path)
bool filter_url_get_write_permission (std::string path)
{
#ifdef HAVE_WINDOWS
wstring wpath = filter::strings::string2wstring (path);
std::wstring wpath = filter::strings::string2wstring (path);
int result = _waccess (wpath.c_str (), 06);
#else
int result = access (path.c_str(), W_OK);
Expand All @@ -621,7 +621,7 @@ bool filter_url_get_write_permission (std::string path)
void filter_url_set_write_permission (std::string path)
{
#ifdef HAVE_WINDOWS
wstring wpath = filter::strings::string2wstring (path);
std::wstring wpath = filter::strings::string2wstring (path);
_wchmod (wpath.c_str (), _S_IREAD | _S_IWRITE);
#else
chmod (path.c_str (), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH);
Expand Down Expand Up @@ -1773,7 +1773,7 @@ std::string filter_url_http_request_mbed (std::string url, std::string& error, c
FILE * file = nullptr;
if (!filename.empty ()) {
#ifdef HAVE_WINDOWS
wstring wfilename = filter::strings::string2wstring (filename);
std::wstring wfilename = filter::strings::string2wstring (filename);
file = _wfopen (wfilename.c_str (), L"w");
#else
file = fopen (filename.c_str (), "w");
Expand Down
4 changes: 2 additions & 2 deletions webserver/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void http_server ()

#ifdef HAVE_WINDOWS
bool server_accepting_flag {false};
mutex server_accepting_mutex;
std::mutex server_accepting_mutex;


void http_server_acceptor_processor (SOCKET listen_socket)
Expand Down Expand Up @@ -479,7 +479,7 @@ void http_server ()
server_accepting_mutex.unlock ();
if (start_acceptor) {
// Handle waiting for and processing the request in a thread, enabling parallel requests.
thread request_thread = thread (http_server_acceptor_processor, listen_socket);
std::thread request_thread = std::thread (http_server_acceptor_processor, listen_socket);
// Detach and delete thread object.
request_thread.detach ();
}
Expand Down

0 comments on commit eb9a385

Please sign in to comment.