File wont save [SLOVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: File wont save

Post by Andlac028 »

zalander wrote: Sat Jun 17, 2023 5:28 pm
Andlac028 wrote: Sat Jun 17, 2023 2:19 pm
zalander wrote: Sat Jun 17, 2023 4:32 am I added this to the love.update function and it tells me that the file name is illegal or is insecure

Code: Select all

	if love.keyboard.isDown("return") then
            local success, message = love.filesystem.write(game.file_n, game.txt)
            if success then
                print("File saved successfully!")
            else
                print("Error saving file:", message)
            end
        end
And what is the filename?
The file name can differ as the user enters it.
Ok, tell me, what is the filename and content when error is thrown (eg add print with all parameters as in love.filesystem.write to print with error)
yal2du
Prole
Posts: 42
Joined: Wed Oct 13, 2021 5:41 pm

Re: File wont save

Post by yal2du »

The file name can differ as the user enters it.
https://love2d.org/wiki/love.filesystem

prob need to sanitize the user input. love.filesystem.write will only write to specific directories (detailed in docs above) and it sounds like the path being specified isn't one of them.
User avatar
zorg
Party member
Posts: 3449
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File wont save

Post by zorg »

It should only be a filename, and not a full path though; otherwise most characters should be accepted as names anyway.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
zalander
Citizen
Posts: 73
Joined: Mon Jan 09, 2023 5:58 am
Location: India

Re: File wont save

Post by zalander »

zorg wrote: Sun Jun 18, 2023 4:09 am It should only be a filename, and not a full path though; otherwise most characters should be accepted as names anyway.
its just the file name not the full path
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
User avatar
zalander
Citizen
Posts: 73
Joined: Mon Jan 09, 2023 5:58 am
Location: India

Re: File wont save

Post by zalander »

ohhh i got it my code adds a "\b" that needs to be removed before saving the file thanks for the help guys !
:awesome:
Using LOVE to make everything except games :crazy:

Code: Select all

astring = "pog"
print(astring)
--pog
User avatar
zorg
Party member
Posts: 3449
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: File wont save

Post by zorg »

You're welcome, although for future reference, playing one question - one partial answer might not be the best of ideas; i believe that if you posted all relevant code we might have solved this in just one post.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 9 guests