mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Use std::filesystem::path
This commit is contained in:
parent
ec4ac1afc4
commit
5f2c7bb898
@ -17,7 +17,7 @@
|
|||||||
#define GL_SRGB8_ALPHA8 0x8C43
|
#define GL_SRGB8_ALPHA8 0x8C43
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string resourcesDir()
|
std::filesystem::path resourcesDir()
|
||||||
{
|
{
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
return "";
|
return "";
|
||||||
@ -51,13 +51,13 @@ int main()
|
|||||||
// Create a sprite for the background
|
// Create a sprite for the background
|
||||||
sf::Texture backgroundTexture;
|
sf::Texture backgroundTexture;
|
||||||
backgroundTexture.setSrgb(sRgb);
|
backgroundTexture.setSrgb(sRgb);
|
||||||
if (!backgroundTexture.loadFromFile(resourcesDir() + "background.jpg"))
|
if (!backgroundTexture.loadFromFile(resourcesDir() / "background.jpg"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
sf::Sprite background(backgroundTexture);
|
sf::Sprite background(backgroundTexture);
|
||||||
|
|
||||||
// Create some text to draw on top of our OpenGL object
|
// Create some text to draw on top of our OpenGL object
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile(resourcesDir() + "tuffy.ttf"))
|
if (!font.loadFromFile(resourcesDir() / "tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
sf::Text text("SFML / OpenGL demo", font);
|
sf::Text text("SFML / OpenGL demo", font);
|
||||||
@ -72,7 +72,7 @@ int main()
|
|||||||
|
|
||||||
// Load a texture to apply to our 3D cube
|
// Load a texture to apply to our 3D cube
|
||||||
sf::Texture texture;
|
sf::Texture texture;
|
||||||
if (!texture.loadFromFile(resourcesDir() + "logo.png"))
|
if (!texture.loadFromFile(resourcesDir() / "logo.png"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Attempt to generate a mipmap for our cube texture
|
// Attempt to generate a mipmap for our cube texture
|
||||||
@ -220,7 +220,7 @@ int main()
|
|||||||
if (mipmapEnabled)
|
if (mipmapEnabled)
|
||||||
{
|
{
|
||||||
// We simply reload the texture to disable mipmapping
|
// We simply reload the texture to disable mipmapping
|
||||||
if (!texture.loadFromFile(resourcesDir() + "logo.png"))
|
if (!texture.loadFromFile(resourcesDir() / "logo.png"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
mipmapEnabled = false;
|
mipmapEnabled = false;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <SFML/Main.hpp>
|
#include <SFML/Main.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string resourcesDir()
|
std::filesystem::path resourcesDir()
|
||||||
{
|
{
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
return "";
|
return "";
|
||||||
@ -44,13 +44,13 @@ int main()
|
|||||||
|
|
||||||
// Load the sounds used in the game
|
// Load the sounds used in the game
|
||||||
sf::SoundBuffer ballSoundBuffer;
|
sf::SoundBuffer ballSoundBuffer;
|
||||||
if (!ballSoundBuffer.loadFromFile(resourcesDir() + "ball.wav"))
|
if (!ballSoundBuffer.loadFromFile(resourcesDir() / "ball.wav"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
sf::Sound ballSound(ballSoundBuffer);
|
sf::Sound ballSound(ballSoundBuffer);
|
||||||
|
|
||||||
// Create the SFML logo texture:
|
// Create the SFML logo texture:
|
||||||
sf::Texture sfmlLogoTexture;
|
sf::Texture sfmlLogoTexture;
|
||||||
if(!sfmlLogoTexture.loadFromFile(resourcesDir() + "sfml_logo.png"))
|
if(!sfmlLogoTexture.loadFromFile(resourcesDir() / "sfml_logo.png"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
sf::Sprite sfmlLogo;
|
sf::Sprite sfmlLogo;
|
||||||
sfmlLogo.setTexture(sfmlLogoTexture);
|
sfmlLogo.setTexture(sfmlLogoTexture);
|
||||||
@ -82,7 +82,7 @@ int main()
|
|||||||
|
|
||||||
// Load the text font
|
// Load the text font
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile(resourcesDir() + "tuffy.ttf"))
|
if (!font.loadFromFile(resourcesDir() / "tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Initialize the pause message
|
// Initialize the pause message
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -88,7 +89,7 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \return True if the file was successfully opened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool openFromFile(const std::string& filename);
|
[[nodiscard]] bool openFromFile(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Open a sound file in memory for reading
|
/// \brief Open a sound file in memory for reading
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
#include <SFML/Audio/SoundStream.hpp>
|
#include <SFML/Audio/SoundStream.hpp>
|
||||||
#include <SFML/Audio/InputSoundFile.hpp>
|
#include <SFML/Audio/InputSoundFile.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -116,7 +117,7 @@ public:
|
|||||||
/// \see openFromMemory, openFromStream
|
/// \see openFromMemory, openFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool openFromFile(const std::string& filename);
|
[[nodiscard]] bool openFromFile(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Open a music from an audio file in memory
|
/// \brief Open a music from an audio file in memory
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \return True if the file was successfully opened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool openFromFile(const std::string& filename, unsigned int sampleRate, unsigned int channelCount);
|
[[nodiscard]] bool openFromFile(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Write audio samples to the file
|
/// \brief Write audio samples to the file
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
#include <SFML/Audio/AlResource.hpp>
|
#include <SFML/Audio/AlResource.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
@ -83,7 +84,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream, loadFromSamples, saveToFile
|
/// \see loadFromMemory, loadFromStream, loadFromSamples, saveToFile
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& filename);
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the sound buffer from a file in memory
|
/// \brief Load the sound buffer from a file in memory
|
||||||
@ -147,7 +148,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory, loadFromSamples
|
/// \see loadFromFile, loadFromMemory, loadFromSamples
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool saveToFile(const std::string& filename) const;
|
[[nodiscard]] bool saveToFile(const std::filesystem::path& filename) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the array of audio samples stored in the buffer
|
/// \brief Get the array of audio samples stored in the buffer
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -94,7 +95,7 @@ public:
|
|||||||
/// \see createReaderFromMemory, createReaderFromStream
|
/// \see createReaderFromMemory, createReaderFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static std::unique_ptr<SoundFileReader> createReaderFromFilename(const std::string& filename);
|
static std::unique_ptr<SoundFileReader> createReaderFromFilename(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Instantiate the right codec for the given file in memory
|
/// \brief Instantiate the right codec for the given file in memory
|
||||||
@ -129,7 +130,7 @@ public:
|
|||||||
/// \return A new sound file writer that can write given file, or null if no writer can handle it
|
/// \return A new sound file writer that can write given file, or null if no writer can handle it
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static std::unique_ptr<SoundFileWriter> createWriterFromFilename(const std::string& filename);
|
static std::unique_ptr<SoundFileWriter> createWriterFromFilename(const std::filesystem::path& filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ private:
|
|||||||
|
|
||||||
struct WriterFactory
|
struct WriterFactory
|
||||||
{
|
{
|
||||||
bool (*check)(const std::string&);
|
bool (*check)(const std::filesystem::path&);
|
||||||
std::unique_ptr<SoundFileWriter> (*create)();
|
std::unique_ptr<SoundFileWriter> (*create)();
|
||||||
};
|
};
|
||||||
using WriterFactoryArray = std::vector<WriterFactory>;
|
using WriterFactoryArray = std::vector<WriterFactory>;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.hpp>
|
#include <SFML/Audio/Export.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \return True if the file was successfully opened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] virtual bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) = 0;
|
[[nodiscard]] virtual bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Write audio samples to the open file
|
/// \brief Write audio samples to the open file
|
||||||
@ -97,13 +98,13 @@ public:
|
|||||||
/// {
|
/// {
|
||||||
/// public:
|
/// public:
|
||||||
///
|
///
|
||||||
/// [[nodiscard]] static bool check(const std::string& filename)
|
/// [[nodiscard]] static bool check(const std::filesystem::path& filename)
|
||||||
/// {
|
/// {
|
||||||
/// // typically, check the extension
|
/// // typically, check the extension
|
||||||
/// // return true if the writer can handle the format
|
/// // return true if the writer can handle the format
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// [[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override
|
/// [[nodiscard]] bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) override
|
||||||
/// {
|
/// {
|
||||||
/// // open the file 'filename' for writing,
|
/// // open the file 'filename' for writing,
|
||||||
/// // write the given sample rate and channel count to the file header
|
/// // write the given sample rate and channel count to the file header
|
||||||
|
@ -124,7 +124,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& filename);
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the font from a file in memory
|
/// \brief Load the font from a file in memory
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream, saveToFile
|
/// \see loadFromMemory, loadFromStream, saveToFile
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& filename);
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the image from a file in memory
|
/// \brief Load the image from a file in memory
|
||||||
@ -177,7 +178,7 @@ public:
|
|||||||
/// \see create, loadFromFile, loadFromMemory
|
/// \see create, loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool saveToFile(const std::string& filename) const;
|
[[nodiscard]] bool saveToFile(const std::filesystem::path& filename) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Save the image to a buffer in memory
|
/// \brief Save the image to a buffer in memory
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <SFML/Window/GlResource.hpp>
|
#include <SFML/Window/GlResource.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& filename, Type type);
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& filename, Type type);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load both the vertex and fragment shaders from files
|
/// \brief Load both the vertex and fragment shaders from files
|
||||||
@ -148,7 +149,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& fragmentShaderFilename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry and fragment shaders from files
|
/// \brief Load the vertex, geometry and fragment shaders from files
|
||||||
@ -170,7 +171,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename);
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& geometryShaderFilename, const std::filesystem::path& fragmentShaderFilename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry or fragment shader from a source code in memory
|
/// \brief Load the vertex, geometry or fragment shader from a source code in memory
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SFML/Graphics/Export.hpp>
|
#include <SFML/Graphics/Export.hpp>
|
||||||
#include <SFML/Window/GlResource.hpp>
|
#include <SFML/Window/GlResource.hpp>
|
||||||
#include <SFML/Graphics/Rect.hpp>
|
#include <SFML/Graphics/Rect.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
@ -127,7 +128,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream, loadFromImage
|
/// \see loadFromMemory, loadFromStream, loadFromImage
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool loadFromFile(const std::string& filename, const IntRect& area = IntRect());
|
[[nodiscard]] bool loadFromFile(const std::filesystem::path& filename, const IntRect& area = IntRect());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the texture from a file in memory
|
/// \brief Load the texture from a file in memory
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SFML/Network/Export.hpp>
|
#include <SFML/Network/Export.hpp>
|
||||||
#include <SFML/Network/TcpSocket.hpp>
|
#include <SFML/Network/TcpSocket.hpp>
|
||||||
#include <SFML/System/Time.hpp>
|
#include <SFML/System/Time.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -202,14 +203,14 @@ public:
|
|||||||
/// \return Directory name
|
/// \return Directory name
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const std::string& getDirectory() const;
|
const std::filesystem::path& getDirectory() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::string m_directory; //!< Directory extracted from the response message
|
std::filesystem::path m_directory; //!< Directory extracted from the response message
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -442,7 +443,7 @@ public:
|
|||||||
/// \see deleteFile
|
/// \see deleteFile
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] Response renameFile(const std::string& file, const std::string& newName);
|
[[nodiscard]] Response renameFile(const std::filesystem::path& file, const std::filesystem::path& newName);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Remove an existing file
|
/// \brief Remove an existing file
|
||||||
@ -459,7 +460,7 @@ public:
|
|||||||
/// \see renameFile
|
/// \see renameFile
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] Response deleteFile(const std::string& name);
|
[[nodiscard]] Response deleteFile(const std::filesystem::path& name);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Download a file from the server
|
/// \brief Download a file from the server
|
||||||
@ -481,7 +482,7 @@ public:
|
|||||||
/// \see upload
|
/// \see upload
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
|
[[nodiscard]] Response download(const std::filesystem::path& remoteFile, const std::filesystem::path& localPath, TransferMode mode = Binary);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Upload a file to the server
|
/// \brief Upload a file to the server
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#ifdef SFML_SYSTEM_ANDROID
|
||||||
namespace sf::priv
|
namespace sf::priv
|
||||||
@ -96,7 +97,7 @@ public:
|
|||||||
/// \return True on success, false on error
|
/// \return True on success, false on error
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool open(const std::string& filename);
|
[[nodiscard]] bool open(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Read data from the stream
|
/// \brief Read data from the stream
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// ZipStream(const std::string& archive);
|
/// ZipStream(const std::string& archive);
|
||||||
///
|
///
|
||||||
/// [[nodiscard]] bool open(const std::string& filename);
|
/// [[nodiscard]] bool open(const std::filesystem::path& filename);
|
||||||
///
|
///
|
||||||
/// [[nodiscard]] Int64 read(void* data, Int64 size);
|
/// [[nodiscard]] Int64 read(void* data, Int64 size);
|
||||||
///
|
///
|
||||||
|
@ -43,14 +43,13 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void alCheckError(const char* file, unsigned int line, const char* expression)
|
void alCheckError(const std::filesystem::path& file, unsigned int line, const char* expression)
|
||||||
{
|
{
|
||||||
// Get the last error
|
// Get the last error
|
||||||
ALenum errorCode = alGetError();
|
ALenum errorCode = alGetError();
|
||||||
|
|
||||||
if (errorCode != AL_NO_ERROR)
|
if (errorCode != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
std::string fileString = file;
|
|
||||||
std::string error = "Unknown error";
|
std::string error = "Unknown error";
|
||||||
std::string description = "No description";
|
std::string description = "No description";
|
||||||
|
|
||||||
@ -95,7 +94,7 @@ void alCheckError(const char* file, unsigned int line, const char* expression)
|
|||||||
|
|
||||||
// Log the error
|
// Log the error
|
||||||
err() << "An internal OpenAL call failed in "
|
err() << "An internal OpenAL call failed in "
|
||||||
<< fileString.substr(fileString.find_last_of("\\/") + 1) << "(" << line << ")."
|
<< file.filename() << "(" << line << ")."
|
||||||
<< "\nExpression:\n " << expression
|
<< "\nExpression:\n " << expression
|
||||||
<< "\nError description:\n " << error << "\n " << description << '\n'
|
<< "\nError description:\n " << error << "\n " << description << '\n'
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
@ -72,7 +73,7 @@ namespace priv
|
|||||||
/// \param expression The evaluated expression as a string
|
/// \param expression The evaluated expression as a string
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void alCheckError(const char* file, unsigned int line, const char* expression);
|
void alCheckError(const std::filesystem::path& file, unsigned int line, const char* expression);
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ AudioDevice::~AudioDevice()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
bool AudioDevice::isExtensionSupported(const std::filesystem::path& extension)
|
||||||
{
|
{
|
||||||
// Create a temporary audio device in case none exists yet.
|
// Create a temporary audio device in case none exists yet.
|
||||||
// This device will not be used in this function and merely
|
// This device will not be used in this function and merely
|
||||||
@ -119,10 +119,10 @@ bool AudioDevice::isExtensionSupported(const std::string& extension)
|
|||||||
if (!audioDevice)
|
if (!audioDevice)
|
||||||
device.emplace();
|
device.emplace();
|
||||||
|
|
||||||
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
if ((extension.string().length() > 2) && (extension.string().substr(0, 3) == "ALC"))
|
||||||
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
return alcIsExtensionPresent(audioDevice, extension.string().c_str()) != AL_FALSE;
|
||||||
else
|
else
|
||||||
return alIsExtensionPresent(extension.c_str()) != AL_FALSE;
|
return alIsExtensionPresent(extension.string().c_str()) != AL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
#include <string>
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
/// \return True if the extension is supported, false if not
|
/// \return True if the extension is supported, false if not
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static bool isExtensionSupported(const std::string& extension);
|
static bool isExtensionSupported(const std::filesystem::path& extension);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the OpenAL format that matches the given number of channels
|
/// \brief Get the OpenAL format that matches the given number of channels
|
||||||
|
@ -84,7 +84,7 @@ InputSoundFile::~InputSoundFile()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool InputSoundFile::openFromFile(const std::string& filename)
|
bool InputSoundFile::openFromFile(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
// If the file is already open, first close it
|
// If the file is already open, first close it
|
||||||
close();
|
close();
|
||||||
|
@ -62,7 +62,7 @@ Music::~Music()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Music::openFromFile(const std::string& filename)
|
bool Music::openFromFile(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
// First stop the music if it was already running
|
// First stop the music if it was already running
|
||||||
stop();
|
stop();
|
||||||
|
@ -48,7 +48,7 @@ OutputSoundFile::~OutputSoundFile()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool OutputSoundFile::openFromFile(const std::string& filename, unsigned int sampleRate, unsigned int channelCount)
|
bool OutputSoundFile::openFromFile(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount)
|
||||||
{
|
{
|
||||||
// If the file is already open, first close it
|
// If the file is already open, first close it
|
||||||
close();
|
close();
|
||||||
|
@ -92,7 +92,7 @@ SoundBuffer::~SoundBuffer()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundBuffer::loadFromFile(const std::string& filename)
|
bool SoundBuffer::loadFromFile(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
InputSoundFile file;
|
InputSoundFile file;
|
||||||
if (file.openFromFile(filename))
|
if (file.openFromFile(filename))
|
||||||
@ -151,7 +151,7 @@ bool SoundBuffer::loadFromSamples(const Int16* samples, Uint64 sampleCount, unsi
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundBuffer::saveToFile(const std::string& filename) const
|
bool SoundBuffer::saveToFile(const std::filesystem::path& filename) const
|
||||||
{
|
{
|
||||||
// Create the sound file in write mode
|
// Create the sound file in write mode
|
||||||
OutputSoundFile file;
|
OutputSoundFile file;
|
||||||
|
@ -66,7 +66,7 @@ SoundFileFactory::WriterFactoryArray SoundFileFactory::s_writers;
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromFilename(const std::string& filename)
|
std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromFilename(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
// Register the built-in readers/writers on first call
|
// Register the built-in readers/writers on first call
|
||||||
ensureDefaultReadersWritersRegistered();
|
ensureDefaultReadersWritersRegistered();
|
||||||
@ -152,7 +152,7 @@ std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromStream(InputS
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::unique_ptr<SoundFileWriter> SoundFileFactory::createWriterFromFilename(const std::string& filename)
|
std::unique_ptr<SoundFileWriter> SoundFileFactory::createWriterFromFilename(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
// Register the built-in readers/writers on first call
|
// Register the built-in readers/writers on first call
|
||||||
ensureDefaultReadersWritersRegistered();
|
ensureDefaultReadersWritersRegistered();
|
||||||
|
@ -39,11 +39,9 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundFileWriterFlac::check(const std::string& filename)
|
bool SoundFileWriterFlac::check(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
const std::string extension = toLower(filename.substr(filename.find_last_of('.') + 1));
|
return toLower(filename.extension().string()) == ".flac";
|
||||||
|
|
||||||
return extension == "flac";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +62,7 @@ SoundFileWriterFlac::~SoundFileWriterFlac()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundFileWriterFlac::open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount)
|
bool SoundFileWriterFlac::open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount)
|
||||||
{
|
{
|
||||||
// Create the encoder
|
// Create the encoder
|
||||||
m_encoder = FLAC__stream_encoder_new();
|
m_encoder = FLAC__stream_encoder_new();
|
||||||
@ -80,7 +78,7 @@ bool SoundFileWriterFlac::open(const std::string& filename, unsigned int sampleR
|
|||||||
FLAC__stream_encoder_set_sample_rate(m_encoder, sampleRate);
|
FLAC__stream_encoder_set_sample_rate(m_encoder, sampleRate);
|
||||||
|
|
||||||
// Initialize the output stream
|
// Initialize the output stream
|
||||||
if (FLAC__stream_encoder_init_file(m_encoder, filename.c_str(), nullptr, nullptr) != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
if (FLAC__stream_encoder_init_file(m_encoder, filename.string().c_str(), nullptr, nullptr) != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
|
||||||
{
|
{
|
||||||
err() << "Failed to write flac file \"" << filename << "\" (failed to open the file)" << std::endl;
|
err() << "Failed to write flac file \"" << filename << "\" (failed to open the file)" << std::endl;
|
||||||
close();
|
close();
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/SoundFileWriter.hpp>
|
#include <SFML/Audio/SoundFileWriter.hpp>
|
||||||
#include <FLAC/stream_encoder.h>
|
#include <FLAC/stream_encoder.h>
|
||||||
|
#include <filesystem>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public:
|
|||||||
/// \return True if the file can be written by this writer
|
/// \return True if the file can be written by this writer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] static bool check(const std::string& filename);
|
[[nodiscard]] static bool check(const std::filesystem::path& filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \return True if the file was successfully opened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
[[nodiscard]] bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Write audio samples to the open file
|
/// \brief Write audio samples to the open file
|
||||||
|
@ -40,11 +40,9 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundFileWriterOgg::check(const std::string& filename)
|
bool SoundFileWriterOgg::check(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
const std::string extension = toLower(filename.substr(filename.find_last_of('.') + 1));
|
return toLower(filename.extension().string()) == ".ogg";
|
||||||
|
|
||||||
return extension == "ogg";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +65,7 @@ SoundFileWriterOgg::~SoundFileWriterOgg()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundFileWriterOgg::open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount)
|
bool SoundFileWriterOgg::open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount)
|
||||||
{
|
{
|
||||||
// Save the channel count
|
// Save the channel count
|
||||||
m_channelCount = channelCount;
|
m_channelCount = channelCount;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/SoundFileWriter.hpp>
|
#include <SFML/Audio/SoundFileWriter.hpp>
|
||||||
#include <vorbis/vorbisenc.h>
|
#include <vorbis/vorbisenc.h>
|
||||||
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public:
|
|||||||
/// \return True if the file can be written by this writer
|
/// \return True if the file can be written by this writer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] static bool check(const std::string& filename);
|
[[nodiscard]] static bool check(const std::filesystem::path& filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \return True if the file was successfully opened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
[[nodiscard]] bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Write audio samples to the open file
|
/// \brief Write audio samples to the open file
|
||||||
|
@ -75,11 +75,9 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundFileWriterWav::check(const std::string& filename)
|
bool SoundFileWriterWav::check(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
const std::string extension = toLower(filename.substr(filename.find_last_of('.') + 1));
|
return toLower(filename.extension().string()) == ".wav";
|
||||||
|
|
||||||
return extension == "wav";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +96,7 @@ SoundFileWriterWav::~SoundFileWriterWav()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool SoundFileWriterWav::open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount)
|
bool SoundFileWriterWav::open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount)
|
||||||
{
|
{
|
||||||
// Open the file
|
// Open the file
|
||||||
m_file.open(filename.c_str(), std::ios::binary);
|
m_file.open(filename.c_str(), std::ios::binary);
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
/// \return True if the file can be written by this writer
|
/// \return True if the file can be written by this writer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] static bool check(const std::string& filename);
|
[[nodiscard]] static bool check(const std::filesystem::path& filename);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public:
|
|||||||
/// \return True if the file was successfully opened
|
/// \return True if the file was successfully opened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool open(const std::string& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
[[nodiscard]] bool open(const std::filesystem::path& filename, unsigned int sampleRate, unsigned int channelCount) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Write audio samples to the open file
|
/// \brief Write audio samples to the open file
|
||||||
|
@ -144,7 +144,7 @@ Font& Font::operator=(Font&&) noexcept = default;
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Font::loadFromFile(const std::string& filename)
|
bool Font::loadFromFile(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
#ifndef SFML_SYSTEM_ANDROID
|
#ifndef SFML_SYSTEM_ANDROID
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ bool Font::loadFromFile(const std::string& filename)
|
|||||||
|
|
||||||
// Load the new font face from the specified file
|
// Load the new font face from the specified file
|
||||||
FT_Face face;
|
FT_Face face;
|
||||||
if (FT_New_Face(library, filename.c_str(), 0, &face) != 0)
|
if (FT_New_Face(library, filename.string().c_str(), 0, &face) != 0)
|
||||||
{
|
{
|
||||||
err() << "Failed to load font \"" << filename << "\" (failed to create the font face)" << std::endl;
|
err() << "Failed to load font \"" << filename << "\" (failed to create the font face)" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,14 +36,13 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void glCheckError(const char* file, unsigned int line, const char* expression)
|
void glCheckError(const std::filesystem::path& file, unsigned int line, const char* expression)
|
||||||
{
|
{
|
||||||
// Get the last error
|
// Get the last error
|
||||||
GLenum errorCode = glGetError();
|
GLenum errorCode = glGetError();
|
||||||
|
|
||||||
if (errorCode != GL_NO_ERROR)
|
if (errorCode != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
std::string fileString = file;
|
|
||||||
std::string error = "Unknown error";
|
std::string error = "Unknown error";
|
||||||
std::string description = "No description";
|
std::string description = "No description";
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ void glCheckError(const char* file, unsigned int line, const char* expression)
|
|||||||
|
|
||||||
// Log the error
|
// Log the error
|
||||||
err() << "An internal OpenGL call failed in "
|
err() << "An internal OpenGL call failed in "
|
||||||
<< fileString.substr(fileString.find_last_of("\\/") + 1) << "(" << line << ")."
|
<< file.filename() << "(" << line << ")."
|
||||||
<< "\nExpression:\n " << expression
|
<< "\nExpression:\n " << expression
|
||||||
<< "\nError description:\n " << error << "\n " << description << '\n'
|
<< "\nError description:\n " << error << "\n " << description << '\n'
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
#include <SFML/Graphics/GLExtensions.hpp>
|
#include <SFML/Graphics/GLExtensions.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -60,7 +61,7 @@ namespace priv
|
|||||||
/// \param expression The evaluated expression as a string
|
/// \param expression The evaluated expression as a string
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void glCheckError(const char* file, unsigned int line, const char* expression);
|
void glCheckError(const std::filesystem::path& file, unsigned int line, const char* expression);
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void Image::create(unsigned int width, unsigned int height, const Uint8* pixels)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Image::loadFromFile(const std::string& filename)
|
bool Image::loadFromFile(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
#ifndef SFML_SYSTEM_ANDROID
|
#ifndef SFML_SYSTEM_ANDROID
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ bool Image::loadFromStream(InputStream& stream)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Image::saveToFile(const std::string& filename) const
|
bool Image::saveToFile(const std::filesystem::path& filename) const
|
||||||
{
|
{
|
||||||
return priv::ImageLoader::getInstance().saveImageToFile(filename, m_pixels, m_size);
|
return priv::ImageLoader::getInstance().saveImageToFile(filename, m_pixels, m_size);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <stb_image.h>
|
#include <stb_image.h>
|
||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
#include <stb_image_write.h>
|
#include <stb_image_write.h>
|
||||||
|
#include <filesystem>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ ImageLoader::~ImageLoader()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool ImageLoader::loadImageFromFile(const std::string& filename, std::vector<Uint8>& pixels, Vector2u& size)
|
bool ImageLoader::loadImageFromFile(const std::filesystem::path& filename, std::vector<Uint8>& pixels, Vector2u& size)
|
||||||
{
|
{
|
||||||
// Clear the array (just in case)
|
// Clear the array (just in case)
|
||||||
pixels.clear();
|
pixels.clear();
|
||||||
@ -105,7 +106,7 @@ bool ImageLoader::loadImageFromFile(const std::string& filename, std::vector<Uin
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
int channels = 0;
|
int channels = 0;
|
||||||
unsigned char* ptr = stbi_load(filename.c_str(), &width, &height, &channels, STBI_rgb_alpha);
|
unsigned char* ptr = stbi_load(filename.string().c_str(), &width, &height, &channels, STBI_rgb_alpha);
|
||||||
|
|
||||||
if (ptr)
|
if (ptr)
|
||||||
{
|
{
|
||||||
@ -239,7 +240,7 @@ bool ImageLoader::loadImageFromStream(InputStream& stream, std::vector<Uint8>& p
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool ImageLoader::saveImageToFile(const std::string& filename, const std::vector<Uint8>& pixels, const Vector2u& size)
|
bool ImageLoader::saveImageToFile(const std::filesystem::path& filename, const std::vector<Uint8>& pixels, const Vector2u& size)
|
||||||
{
|
{
|
||||||
// Make sure the image is not empty
|
// Make sure the image is not empty
|
||||||
if (!pixels.empty() && (size.x > 0) && (size.y > 0))
|
if (!pixels.empty() && (size.x > 0) && (size.y > 0))
|
||||||
@ -247,32 +248,31 @@ bool ImageLoader::saveImageToFile(const std::string& filename, const std::vector
|
|||||||
// Deduce the image type from its extension
|
// Deduce the image type from its extension
|
||||||
|
|
||||||
// Extract the extension
|
// Extract the extension
|
||||||
const std::size_t dot = filename.find_last_of('.');
|
const std::filesystem::path extension = filename.extension();
|
||||||
const std::string extension = dot != std::string::npos ? toLower(filename.substr(dot + 1)) : "";
|
|
||||||
const Vector2i convertedSize = Vector2i(size);
|
const Vector2i convertedSize = Vector2i(size);
|
||||||
|
|
||||||
if (extension == "bmp")
|
if (extension == ".bmp")
|
||||||
{
|
{
|
||||||
// BMP format
|
// BMP format
|
||||||
if (stbi_write_bmp(filename.c_str(), convertedSize.x, convertedSize.y, 4, pixels.data()))
|
if (stbi_write_bmp(filename.string().c_str(), convertedSize.x, convertedSize.y, 4, pixels.data()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (extension == "tga")
|
else if (extension == ".tga")
|
||||||
{
|
{
|
||||||
// TGA format
|
// TGA format
|
||||||
if (stbi_write_tga(filename.c_str(), convertedSize.x, convertedSize.y, 4, pixels.data()))
|
if (stbi_write_tga(filename.string().c_str(), convertedSize.x, convertedSize.y, 4, pixels.data()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (extension == "png")
|
else if (extension == ".png")
|
||||||
{
|
{
|
||||||
// PNG format
|
// PNG format
|
||||||
if (stbi_write_png(filename.c_str(), convertedSize.x, convertedSize.y, 4, pixels.data(), 0))
|
if (stbi_write_png(filename.string().c_str(), convertedSize.x, convertedSize.y, 4, pixels.data(), 0))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (extension == "jpg" || extension == "jpeg")
|
else if (extension == ".jpg" || extension == ".jpeg")
|
||||||
{
|
{
|
||||||
// JPG format
|
// JPG format
|
||||||
if (stbi_write_jpg(filename.c_str(), convertedSize.x, convertedSize.y, 4, pixels.data(), 90))
|
if (stbi_write_jpg(filename.string().c_str(), convertedSize.x, convertedSize.y, 4, pixels.data(), 90))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ public:
|
|||||||
/// \return True if loading was successful
|
/// \return True if loading was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadImageFromFile(const std::string& filename, std::vector<Uint8>& pixels, Vector2u& size);
|
bool loadImageFromFile(const std::filesystem::path& filename, std::vector<Uint8>& pixels, Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load an image from a file in memory
|
/// \brief Load an image from a file in memory
|
||||||
@ -103,7 +104,7 @@ public:
|
|||||||
/// \return True if saving was successful
|
/// \return True if saving was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool saveImageToFile(const std::string& filename, const std::vector<Uint8>& pixels, const Vector2u& size);
|
bool saveImageToFile(const std::filesystem::path& filename, const std::vector<Uint8>& pixels, const Vector2u& size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Save an array of pixels as an encoded image buffer
|
/// \brief Save an array of pixels as an encoded image buffer
|
||||||
|
@ -74,7 +74,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the contents of a file into an array of char
|
// Read the contents of a file into an array of char
|
||||||
bool getFileContents(const std::string& filename, std::vector<char>& buffer)
|
bool getFileContents(const std::filesystem::path& filename, std::vector<char>& buffer)
|
||||||
{
|
{
|
||||||
std::ifstream file(filename.c_str(), std::ios_base::binary);
|
std::ifstream file(filename.c_str(), std::ios_base::binary);
|
||||||
if (file)
|
if (file)
|
||||||
@ -253,7 +253,7 @@ Shader::~Shader()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Shader::loadFromFile(const std::string& filename, Type type)
|
bool Shader::loadFromFile(const std::filesystem::path& filename, Type type)
|
||||||
{
|
{
|
||||||
// Read the file
|
// Read the file
|
||||||
std::vector<char> shader;
|
std::vector<char> shader;
|
||||||
@ -274,7 +274,7 @@ bool Shader::loadFromFile(const std::string& filename, Type type)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename)
|
bool Shader::loadFromFile(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& fragmentShaderFilename)
|
||||||
{
|
{
|
||||||
// Read the vertex shader file
|
// Read the vertex shader file
|
||||||
std::vector<char> vertexShader;
|
std::vector<char> vertexShader;
|
||||||
@ -298,7 +298,7 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename)
|
bool Shader::loadFromFile(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& geometryShaderFilename, const std::filesystem::path& fragmentShaderFilename)
|
||||||
{
|
{
|
||||||
// Read the vertex shader file
|
// Read the vertex shader file
|
||||||
std::vector<char> vertexShader;
|
std::vector<char> vertexShader;
|
||||||
@ -977,21 +977,21 @@ Shader::~Shader()
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Shader::loadFromFile(const std::string& /* filename */, Type /* type */)
|
bool Shader::loadFromFile(const std::filesystem::path& /* filename */, Type /* type */)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Shader::loadFromFile(const std::string& /* vertexShaderFilename */, const std::string& /* fragmentShaderFilename */)
|
bool Shader::loadFromFile(const std::filesystem::path& /* vertexShaderFilename */, const std::filesystem::path& /* fragmentShaderFilename */)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Shader::loadFromFile(const std::string& /* vertexShaderFilename */, const std::string& /* geometryShaderFilename */, const std::string& /* fragmentShaderFilename */)
|
bool Shader::loadFromFile(const std::filesystem::path& /* vertexShaderFilename */, const std::filesystem::path& /* geometryShaderFilename */, const std::filesystem::path& /* fragmentShaderFilename */)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ bool Texture::create(unsigned int width, unsigned int height)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool Texture::loadFromFile(const std::string& filename, const IntRect& area)
|
bool Texture::loadFromFile(const std::filesystem::path& filename, const IntRect& area)
|
||||||
{
|
{
|
||||||
Image image;
|
Image image;
|
||||||
return image.loadFromFile(filename) && loadFromImage(image, area);
|
return image.loadFromFile(filename) && loadFromImage(image, area);
|
||||||
|
@ -123,7 +123,7 @@ Ftp::Response(response)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const std::string& Ftp::DirectoryResponse::getDirectory() const
|
const std::filesystem::path& Ftp::DirectoryResponse::getDirectory() const
|
||||||
{
|
{
|
||||||
return m_directory;
|
return m_directory;
|
||||||
}
|
}
|
||||||
@ -270,25 +270,25 @@ Ftp::Response Ftp::deleteDirectory(const std::string& name)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Ftp::Response Ftp::renameFile(const std::string& file, const std::string& newName)
|
Ftp::Response Ftp::renameFile(const std::filesystem::path& file, const std::filesystem::path& newName)
|
||||||
{
|
{
|
||||||
Response response = sendCommand("RNFR", file);
|
Response response = sendCommand("RNFR", file.string());
|
||||||
if (response.isOk())
|
if (response.isOk())
|
||||||
response = sendCommand("RNTO", newName);
|
response = sendCommand("RNTO", newName.string());
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Ftp::Response Ftp::deleteFile(const std::string& name)
|
Ftp::Response Ftp::deleteFile(const std::filesystem::path& name)
|
||||||
{
|
{
|
||||||
return sendCommand("DELE", name);
|
return sendCommand("DELE", name.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Ftp::Response Ftp::download(const std::string& remoteFile, const std::string& localPath, TransferMode mode)
|
Ftp::Response Ftp::download(const std::filesystem::path& remoteFile, const std::filesystem::path& localPath, TransferMode mode)
|
||||||
{
|
{
|
||||||
// Open a data channel using the given transfer mode
|
// Open a data channel using the given transfer mode
|
||||||
DataChannel data(*this);
|
DataChannel data(*this);
|
||||||
@ -296,22 +296,12 @@ Ftp::Response Ftp::download(const std::string& remoteFile, const std::string& lo
|
|||||||
if (response.isOk())
|
if (response.isOk())
|
||||||
{
|
{
|
||||||
// Tell the server to start the transfer
|
// Tell the server to start the transfer
|
||||||
response = sendCommand("RETR", remoteFile);
|
response = sendCommand("RETR", remoteFile.string());
|
||||||
if (response.isOk())
|
if (response.isOk())
|
||||||
{
|
{
|
||||||
// Extract the filename from the file path
|
|
||||||
std::string filename = remoteFile;
|
|
||||||
std::string::size_type pos = filename.find_last_of("/\\");
|
|
||||||
if (pos != std::string::npos)
|
|
||||||
filename = filename.substr(pos + 1);
|
|
||||||
|
|
||||||
// Make sure the destination path ends with a slash
|
|
||||||
std::string path = localPath;
|
|
||||||
if (!path.empty() && (path[path.size() - 1] != '\\') && (path[path.size() - 1] != '/'))
|
|
||||||
path += "/";
|
|
||||||
|
|
||||||
// Create the file and truncate it if necessary
|
// Create the file and truncate it if necessary
|
||||||
std::ofstream file((path + filename).c_str(), std::ios_base::binary | std::ios_base::trunc);
|
const std::filesystem::path filepath = localPath / remoteFile.filename();
|
||||||
|
std::ofstream file(filepath, std::ios_base::binary | std::ios_base::trunc);
|
||||||
if (!file)
|
if (!file)
|
||||||
return Response(Response::InvalidFile);
|
return Response(Response::InvalidFile);
|
||||||
|
|
||||||
@ -326,7 +316,7 @@ Ftp::Response Ftp::download(const std::string& remoteFile, const std::string& lo
|
|||||||
|
|
||||||
// If the download was unsuccessful, delete the partial file
|
// If the download was unsuccessful, delete the partial file
|
||||||
if (!response.isOk())
|
if (!response.isOk())
|
||||||
std::remove((path + filename).c_str());
|
std::remove(filepath.string().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace priv
|
|||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
ResourceStream::ResourceStream(const std::string& filename) :
|
ResourceStream::ResourceStream(const std::filesystem::path& filename) :
|
||||||
m_file (nullptr)
|
m_file (nullptr)
|
||||||
{
|
{
|
||||||
ActivityStates& states = getActivity();
|
ActivityStates& states = getActivity();
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <SFML/System/Export.hpp>
|
#include <SFML/System/Export.hpp>
|
||||||
#include <SFML/System/InputStream.hpp>
|
#include <SFML/System/InputStream.hpp>
|
||||||
#include <android/asset_manager.h>
|
#include <android/asset_manager.h>
|
||||||
|
#include <filesystem>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public:
|
|||||||
/// \param filename Filename of the asset
|
/// \param filename Filename of the asset
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
ResourceStream(const std::string& filename);
|
ResourceStream(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
|
@ -60,13 +60,17 @@ FileInputStream& FileInputStream::operator=(FileInputStream&&) = default;
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool FileInputStream::open(const std::string& filename)
|
bool FileInputStream::open(const std::filesystem::path& filename)
|
||||||
{
|
{
|
||||||
#ifdef SFML_SYSTEM_ANDROID
|
#ifdef SFML_SYSTEM_ANDROID
|
||||||
m_file = std::make_unique<priv::ResourceStream>(filename);
|
m_file = std::make_unique<priv::ResourceStream>(filename);
|
||||||
return m_file->tell() != -1;
|
return m_file->tell() != -1;
|
||||||
|
#else
|
||||||
|
#ifdef SFML_SYSTEM_WINDOWS
|
||||||
|
m_file.reset(_wfopen(filename.c_str(), L"rb"));
|
||||||
#else
|
#else
|
||||||
m_file.reset(std::fopen(filename.c_str(), "rb"));
|
m_file.reset(std::fopen(filename.c_str(), "rb"));
|
||||||
|
#endif
|
||||||
return m_file != nullptr;
|
return m_file != nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace sf
|
|||||||
namespace priv
|
namespace priv
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void eglCheckError(const char* file, unsigned int line, const char* expression)
|
void eglCheckError(const std::filesystem::path& file, unsigned int line, const char* expression)
|
||||||
{
|
{
|
||||||
// Obtain information about the success or failure of the most recent EGL
|
// Obtain information about the success or failure of the most recent EGL
|
||||||
// function called in the current thread
|
// function called in the current thread
|
||||||
@ -46,7 +46,6 @@ void eglCheckError(const char* file, unsigned int line, const char* expression)
|
|||||||
|
|
||||||
if (errorCode != EGL_SUCCESS)
|
if (errorCode != EGL_SUCCESS)
|
||||||
{
|
{
|
||||||
std::string fileString(file);
|
|
||||||
std::string error = "unknown error";
|
std::string error = "unknown error";
|
||||||
std::string description = "no description";
|
std::string description = "no description";
|
||||||
|
|
||||||
@ -154,7 +153,7 @@ void eglCheckError(const char* file, unsigned int line, const char* expression)
|
|||||||
|
|
||||||
// Log the error
|
// Log the error
|
||||||
err() << "An internal EGL call failed in "
|
err() << "An internal EGL call failed in "
|
||||||
<< fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : "
|
<< file.filename() << " (" << line << ") : "
|
||||||
<< "\nExpression:\n " << expression
|
<< "\nExpression:\n " << expression
|
||||||
<< "\nError description:\n " << error << "\n " << description << '\n'
|
<< "\nError description:\n " << error << "\n " << description << '\n'
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Config.hpp>
|
#include <SFML/Config.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
||||||
namespace sf
|
namespace sf
|
||||||
@ -59,7 +60,7 @@ namespace priv
|
|||||||
/// \param expression The evaluated expression as a string
|
/// \param expression The evaluated expression as a string
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void eglCheckError(const char* file, unsigned int line, const char* expression);
|
void eglCheckError(const std::filesystem::path& file, unsigned int line, const char* expression);
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
} // namespace sf
|
} // namespace sf
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#ifdef SFML_OPENGL_ES
|
#ifdef SFML_OPENGL_ES
|
||||||
#include <SFML/Window/EglContext.hpp>
|
#include <SFML/Window/EglContext.hpp>
|
||||||
@ -113,7 +114,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the name of the current executable
|
// Find the name of the current executable
|
||||||
std::string findExecutableName()
|
std::filesystem::path findExecutableName()
|
||||||
{
|
{
|
||||||
// We use /proc/self/cmdline to get the command line
|
// We use /proc/self/cmdline to get the command line
|
||||||
// the user used to invoke this instance of the application
|
// the user used to invoke this instance of the application
|
||||||
@ -737,7 +738,7 @@ m_lastInputTime (0)
|
|||||||
// The instance name should be something unique to this invocation
|
// The instance name should be something unique to this invocation
|
||||||
// of the application but is rarely if ever used these days.
|
// of the application but is rarely if ever used these days.
|
||||||
// For simplicity, we retrieve it via the base executable name.
|
// For simplicity, we retrieve it via the base executable name.
|
||||||
std::string executableName = findExecutableName();
|
std::string executableName = findExecutableName().string();
|
||||||
std::vector<char> windowInstance(executableName.size() + 1, 0);
|
std::vector<char> windowInstance(executableName.size() + 1, 0);
|
||||||
std::copy(executableName.begin(), executableName.end(), windowInstance.begin());
|
std::copy(executableName.begin(), executableName.end(), windowInstance.begin());
|
||||||
hint->res_name = windowInstance.data();
|
hint->res_name = windowInstance.data();
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <string>
|
#include <filesystem>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the path to the resource folder.
|
/// \brief Return the path to the resource folder.
|
||||||
@ -38,6 +38,6 @@
|
|||||||
/// with the main bundle or an empty string is there is no bundle.
|
/// with the main bundle or an empty string is there is no bundle.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::string resourcePath(void);
|
std::filesystem::path resourcePath(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,13 +28,14 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include "ResourcePath.hpp"
|
#include "ResourcePath.hpp"
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
std::string resourcePath(void)
|
std::filesystem::path resourcePath(void)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
std::string rpath;
|
std::filesystem::path rpath;
|
||||||
NSBundle* bundle = [NSBundle mainBundle];
|
NSBundle* bundle = [NSBundle mainBundle];
|
||||||
|
|
||||||
if (bundle == nil) {
|
if (bundle == nil) {
|
||||||
|
Loading…
Reference in New Issue
Block a user