Watch
2
0
Fork
You've already forked raylib-cs
0

Add file functions back into Raylib

This commit is contained in:
Rgebee 2022-02-06 12:36:25 +00:00
commit ed0fdca34e

View file

@ -478,10 +478,66 @@ namespace Raylib_cs
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool SaveFileData(sbyte* fileName, void* data, uint bytesToWrite); public static extern CBool SaveFileData(sbyte* fileName, void* data, uint bytesToWrite);
// Load text data from file (read), returns a '\0' terminated string
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern char *LoadFileText(sbyte* fileName);
// Unload file text data allocated by LoadFileText()
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void UnloadFileText(char *text);
// Save text data to file (write), string must be '\0' terminated, returns true on success
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool SaveFileText(sbyte* fileName, char *text);
// Check if file exists
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool FileExists(sbyte* fileName);
// Check if a directory path exists
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool DirectoryExists(sbyte* dirPath);
/// <summary>Check file extension</summary> /// <summary>Check file extension</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool IsFileExtension(sbyte* fileName, sbyte* ext); public static extern CBool IsFileExtension(sbyte* fileName, sbyte* ext);
/// <summary>Get pointer to extension for a filename string (includes dot: '.png')</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte* GetFileExtension(sbyte* fileName);
/// <summary>Get pointer to filename for a path string</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte* GetFileName(sbyte* filePath);
/// <summary>Get filename string without extension (uses static string)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte* GetFileNameWithoutExt(sbyte* filePath);
/// <summary>Get full path for a given fileName with path (uses static string)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte* GetDirectoryPath(sbyte* filePath);
/// <summary>Get previous directory path for a given path (uses static string)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte* GetPrevDirectoryPath(sbyte* dirPath);
/// <summary>Get current working directory (uses static string)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern sbyte* GetWorkingDirectory();
/// <summary>Get filenames in a directory path (memory should be freed)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern char **GetDirectoryFiles(sbyte* dirPath, int *count);
/// <summary>Clear directory files paths buffers (free memory)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern void ClearDirectoryFiles();
/// <summary>Change working directory, return true on success</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool ChangeDirectory(sbyte* dir);
/// <summary>Check if a file has been dropped into window</summary> /// <summary>Check if a file has been dropped into window</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern CBool IsFileDropped(); public static extern CBool IsFileDropped();
@ -498,6 +554,9 @@ namespace Raylib_cs
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern int GetFileModTime(sbyte* fileName); public static extern int GetFileModTime(sbyte* fileName);
// Compression/Encoding functionality
/// <summary>Compress data (DEFLATE algorithm)</summary> /// <summary>Compress data (DEFLATE algorithm)</summary>
[DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)]
public static extern byte* CompressData(byte* data, int dataLength, int* compDataLength); public static extern byte* CompressData(byte* data, int dataLength, int* compDataLength);