]> git.lizzy.rs Git - minetest-m13.git/commitdiff
Add unistd include file to fix POSIX build of filesys.cpp
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 15 May 2021 13:02:54 +0000 (15:02 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 15 May 2021 13:02:54 +0000 (15:02 +0200)
src/filesys.cpp

index 63eac33687dce5ff2766f5a70361ff546f6299b3..7c6efe1e24d6bffbcacee4581e0339f2734226f1 100644 (file)
@@ -31,8 +31,8 @@ namespace fs
 #include <windows.h>
 #include <stdio.h>
 #include <malloc.h>
-#include <tchar.h> 
-#include <wchar.h> 
+#include <tchar.h>
+#include <wchar.h>
 #include <stdio.h>
 
 #define BUFSIZE MAX_PATH
@@ -71,13 +71,13 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
        // Find the first file in the directory.
        hFind = FindFirstFile(DirSpec, &FindFileData);
 
-       if (hFind == INVALID_HANDLE_VALUE) 
+       if (hFind == INVALID_HANDLE_VALUE)
        {
-         _tprintf (TEXT("Invalid file handle. Error is %u.\n"), 
+         _tprintf (TEXT("Invalid file handle. Error is %u.\n"),
                                GetLastError());
          retval = (-1);
-       } 
-       else 
+       }
+       else
        {
                // NOTE:
                // Be very sure to not include '..' in the results, it will
@@ -90,7 +90,7 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
                        listing.push_back(node);
 
                // List all the other files in the directory.
-               while (FindNextFile(hFind, &FindFileData) != 0) 
+               while (FindNextFile(hFind, &FindFileData) != 0)
                {
                        DirListNode node;
                        node.name = FindFileData.cFileName;
@@ -101,9 +101,9 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
 
                dwError = GetLastError();
                FindClose(hFind);
-               if (dwError != ERROR_NO_MORE_FILES) 
+               if (dwError != ERROR_NO_MORE_FILES)
                {
-                _tprintf (TEXT("FindNextFile error. Error is %u.\n"), 
+                _tprintf (TEXT("FindNextFile error. Error is %u.\n"),
                                   dwError);
                retval = (-1);
                goto Cleanup;
@@ -119,7 +119,7 @@ std::vector<DirListNode> GetDirListing(std::string pathstring)
        //for(unsigned int i=0; i<listing.size(); i++){
        //      std::cout<<listing[i].name<<(listing[i].dir?" (dir)":" (file)")<<std::endl;
        //}
-       
+
        return listing;
 }
 
@@ -143,7 +143,7 @@ bool RecursiveDelete(std::string path)
        std::cerr<<"Removing \""<<path<<"\""<<std::endl;
 
        //return false;
-       
+
        // This silly function needs a double-null terminated string...
        // Well, we'll just make sure it has at least two, then.
        path += "\0\0";
@@ -154,7 +154,7 @@ bool RecursiveDelete(std::string path)
        sfo.pFrom = path.c_str();
        sfo.pTo = NULL;
        sfo.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
-       
+
        int r = SHFileOperation(&sfo);
 
        if(r != 0)
@@ -166,6 +166,7 @@ bool RecursiveDelete(std::string path)
 
 #else // POSIX
 
+#include <unistd.h>
 #include <sys/types.h>
 #include <dirent.h>
 #include <errno.h>
@@ -254,11 +255,11 @@ bool RecursiveDelete(std::string path)
        /*
                Execute the 'rm' command directly, by fork() and execve()
        */
-       
+
        std::cerr<<"Removing \""<<path<<"\""<<std::endl;
 
        //return false;
-       
+
        pid_t child_pid = fork();
 
        if(child_pid == 0)
@@ -276,9 +277,9 @@ bool RecursiveDelete(std::string path)
 
                std::cerr<<"Executing '"<<argv[0]<<"' '"<<argv[1]<<"' '"
                                <<argv[2]<<"'"<<std::endl;
-               
+
                execv(argv[0], argv);
-               
+
                // Execv shouldn't return. Failed.
                _exit(1);
        }