Browse Source

Windows fixes

Panagiotis Christopoulos Charitos 4 years ago
parent
commit
8a4bfed7fb
4 changed files with 15 additions and 13 deletions
  1. 1 1
      AnKi/Util/File.cpp
  2. 4 2
      AnKi/Util/Filesystem.h
  3. 8 8
      AnKi/Util/FilesystemWindows.cpp
  4. 2 2
      AnKi/Util/StdTypes.h

+ 1 - 1
AnKi/Util/File.cpp

@@ -395,7 +395,7 @@ Error File::seek(PtrSize offset, FileSeekOrigin origin)
 	else
 	else
 #endif
 #endif
 	{
 	{
-		if(fseek(ANKI_CFILE, offset, I32(origin)) != 0)
+		if(fseek(ANKI_CFILE, (long int)(offset), I32(origin)) != 0)
 		{
 		{
 			ANKI_UTIL_LOGE("fseek() failed");
 			ANKI_UTIL_LOGE("fseek() failed");
 			err = Error::FUNCTION_FAILED;
 			err = Error::FUNCTION_FAILED;

+ 4 - 2
AnKi/Util/Filesystem.h

@@ -31,6 +31,10 @@ void getParentFilepath(const CString& filename, StringAuto& out);
 /// Return true if directory exists?
 /// Return true if directory exists?
 Bool directoryExists(const CString& dir);
 Bool directoryExists(const CString& dir);
 
 
+/// @internal
+ANKI_USE_RESULT Error walkDirectoryTreeInternal(const CString& dir,
+												const Function<Error(const CString&, Bool)>& callback);
+
 /// Walk a directory tree.
 /// Walk a directory tree.
 /// @param dir The dir to walk.
 /// @param dir The dir to walk.
 /// @param alloc An allocator for temp allocations.
 /// @param alloc An allocator for temp allocations.
@@ -45,8 +49,6 @@ Bool directoryExists(const CString& dir);
 template<typename TFunc>
 template<typename TFunc>
 ANKI_USE_RESULT Error walkDirectoryTree(const CString& dir, GenericMemoryPoolAllocator<U8> alloc, TFunc func)
 ANKI_USE_RESULT Error walkDirectoryTree(const CString& dir, GenericMemoryPoolAllocator<U8> alloc, TFunc func)
 {
 {
-	Error walkDirectoryTreeInternal(const CString& dir, const Function<Error(const CString&, Bool)>& callback);
-
 	Function<Error(const CString&, Bool)> f(alloc, func);
 	Function<Error(const CString&, Bool)> f(alloc, func);
 	const Error err = walkDirectoryTreeInternal(dir, f);
 	const Error err = walkDirectoryTreeInternal(dir, f);
 	f.destroy(alloc);
 	f.destroy(alloc);

+ 8 - 8
AnKi/Util/FilesystemWindows.cpp

@@ -94,8 +94,8 @@ Error getTempDirectory(StringAuto& out)
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-static Error walkDirectoryTreeInternal(const CString& dir, void* userData, WalkDirectoryTreeCallback callback,
-									   U baseDirLen)
+static Error walkDirectoryTreeRecursive(const CString& dir, const Function<Error(const CString&, Bool)>& callback,
+										U baseDirLen)
 {
 {
 	// Append something to the path
 	// Append something to the path
 	if(dir.getLength() > MAX_PATH_LEN - 2)
 	if(dir.getLength() > MAX_PATH_LEN - 2)
@@ -141,7 +141,7 @@ static Error walkDirectoryTreeInternal(const CString& dir, void* userData, WalkD
 			Bool isDir = find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
 			Bool isDir = find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
 
 
 			// Compute new path
 			// Compute new path
-			U oldLen = strlen(&dir2[0]);
+			const PtrSize oldLen = strlen(&dir2[0]);
 			if(oldLen + filename.getLength() > MAX_PATH_LEN)
 			if(oldLen + filename.getLength() > MAX_PATH_LEN)
 			{
 			{
 				ANKI_UTIL_LOGE("Path too long");
 				ANKI_UTIL_LOGE("Path too long");
@@ -149,7 +149,7 @@ static Error walkDirectoryTreeInternal(const CString& dir, void* userData, WalkD
 			}
 			}
 
 
 			strcat(&dir2[0], &filename[0]);
 			strcat(&dir2[0], &filename[0]);
-			Error err = callback(&dir2[0] + baseDirLen, userData, isDir);
+			const Error err = callback(&dir2[0] + baseDirLen, isDir);
 			if(err)
 			if(err)
 			{
 			{
 				FindClose(handle);
 				FindClose(handle);
@@ -159,7 +159,7 @@ static Error walkDirectoryTreeInternal(const CString& dir, void* userData, WalkD
 			// Move to next dir
 			// Move to next dir
 			if(isDir)
 			if(isDir)
 			{
 			{
-				Error err = walkDirectoryTreeInternal(&dir2[0], userData, callback, baseDirLen);
+				const Error err = walkDirectoryTreeRecursive(&dir2[0], callback, baseDirLen);
 				if(err)
 				if(err)
 				{
 				{
 					FindClose(handle);
 					FindClose(handle);
@@ -182,10 +182,10 @@ static Error walkDirectoryTreeInternal(const CString& dir, void* userData, WalkD
 	return Error::NONE;
 	return Error::NONE;
 }
 }
 
 
-Error walkDirectoryTree(const CString& dir, void* userData, WalkDirectoryTreeCallback callback)
+Error walkDirectoryTreeInternal(const CString& dir, const Function<Error(const CString&, Bool)>& callback)
 {
 {
 	U baseDirLen = 0;
 	U baseDirLen = 0;
-	U len = dir.getLength();
+	const U len = dir.getLength();
 	if(dir[len - 1] == '/')
 	if(dir[len - 1] == '/')
 	{
 	{
 		baseDirLen = len;
 		baseDirLen = len;
@@ -195,7 +195,7 @@ Error walkDirectoryTree(const CString& dir, void* userData, WalkDirectoryTreeCal
 		baseDirLen = len + 1;
 		baseDirLen = len + 1;
 	}
 	}
 
 
-	return walkDirectoryTreeInternal(dir, userData, callback, baseDirLen);
+	return walkDirectoryTreeRecursive(dir, callback, baseDirLen);
 }
 }
 
 
 } // end namespace anki
 } // end namespace anki

+ 2 - 2
AnKi/Util/StdTypes.h

@@ -267,12 +267,12 @@ static constexpr unsigned long long int operator""_GB(unsigned long long int x)
 
 
 /// @name Time user literals
 /// @name Time user literals
 /// @{
 /// @{
-static constexpr long double operator""_ms(long double x)
+static constexpr Second operator""_ms(long double x)
 {
 {
 	return x / 1000.0;
 	return x / 1000.0;
 }
 }
 
 
-static constexpr long double operator""_ns(long double x)
+static constexpr Second operator""_ns(long double x)
 {
 {
 	return x / 1000000000.0;
 	return x / 1000000000.0;
 }
 }