Browse Source

Make miniwin/misc.cpp portable

pull/44/head
Xadhoom 7 years ago
parent
commit
c452c5db4e
  1. 18
      SourceX/miniwin/misc.cpp
  2. 14
      SourceX/utf8.h

18
SourceX/miniwin/misc.cpp

@ -1,7 +1,3 @@
#ifndef _WIN32
#include <sys/statvfs.h>
#endif
#include <SDL.h>
#include "devilution.h"
@ -108,25 +104,11 @@ UINT GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize)
WINBOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector,
LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters)
{
#ifndef _WIN32
struct statvfs fiData;
int success = statvfs("/", &fiData);
*lpBytesPerSector = fiData.f_frsize;
*lpSectorsPerCluster = 1;
*lpNumberOfFreeClusters = fiData.f_bavail;
*lpTotalNumberOfClusters = fiData.f_blocks;
return success >= 0;
#else
// Todo give windows the real GetDiskFreeSpace
DUMMY();
*lpBytesPerSector = 1;
*lpSectorsPerCluster = 1;
*lpNumberOfFreeClusters = 10 << 20;
*lpTotalNumberOfClusters = 10 << 20;
return true;
#endif
}
/**

14
SourceX/utf8.h

@ -1,13 +1,13 @@
#pragma once
#include <cstdint>
#include <string>
#include <utility>
/* Branchless UTF-8 decoder
*
* This is free and unencumbered software released into the public domain.
*/
#ifndef UTF8_H
#define UTF8_H
#include <stdint.h>
#include <string>
#include <utility>
/* Decode the next character, C, from BUF, reporting errors in E.
*
@ -84,5 +84,3 @@ inline std::string utf8_to_latin1(const char* in)
}
return std::move(ret);
}
#endif

Loading…
Cancel
Save