Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411518 Posts in 69377 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 28, 2024, 03:41:54 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Dumping files in the correct user folder.
Pages: [1]
Print
Author Topic: Dumping files in the correct user folder.  (Read 1547 times)
Oddbob
Guest
« on: December 16, 2009, 07:16:54 PM »

Ok, I guess it's time I started doing this a bit more properly.

With Squid Harder, I'm writing stuff to an .ini file which sits in the program directory, now that's served well enough for now but as I'm going to need to dump this with an installer of sorts soon, obviously for Vista and beyond users, it's a complete crippler if it goes in programs.

So I need to have GM dump the .ini files to the correct user folder where they'll/it'll have proper read/write perms so that I can, well, read/write from/to it.

Thing is, I haven't a clue about this sort of stuff whatsoever and I'm a complete and utter dimwit when it comes to stuff like this so if you can speak slowly and not too technically and drop me a few clues I'd be muchly appreciative.

I need to get this up and running relatively quickly too, so y'know, help! Before I throw a complete flid on it :D
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #1 on: December 16, 2009, 10:17:59 PM »

actually, you cannot currently save .ini files in any other directory besides the working_directory, and that's done automatically. if you use other functions to read and write text files, you can do it, but you can't use the ini functions for that purpose.

from what i remember, gm8 allows you to save .ini files to directories other than the game's directory, i think. but not gm7 or below. my advice though would be to convert to text files, which you can select the specific folder to save in for, because you can't do that with gm7.

alternatively, use file_copy() on the ini file to the new directory. that will move the file. so it'd be a two step process: save the ini file (to the working directory necessarily) then move it to the desired place with the copy function.

you'd of course have to move it back again to the working directory in order to read it.
Logged

Oddbob
Guest
« Reply #2 on: December 16, 2009, 10:20:54 PM »

That's precisely what I needed to know, thanks Paul.

I'm pretty loathe to go the installer route personally, given I prefer a .zip or .rar file but needs must y'know.

Right, I'll get onto that in the next day or so. Much appreciated, man. Bacon saved.
Logged
ChevyRay
Guest
« Reply #3 on: December 16, 2009, 10:59:23 PM »

Just wondering, would it be possible to just write the ini file and then move it to the folder, etc.? Kind of a lame workaround, but it should be possible, no?
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #4 on: December 16, 2009, 11:04:57 PM »

i suggested that too -- i think it's possible. i never did it myself but i see no reason it wouldn't work.
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #5 on: December 17, 2009, 12:18:07 PM »

Wasn't the OP pointing out that you cannot write files to certain dirs in Vista without UAC permission - thus the file the exe is in is not writable if you've written an installer to install to program files.

You can, I think, set the working directory different from the directory the exe starts in, which might solve your problems.
Logged
ஒழுக்கின்மை (Paul Eres)
Level 10
*****


Also known as रिंकू.


View Profile WWW
« Reply #6 on: December 17, 2009, 12:51:46 PM »

oh, i see -- in that case, running the game in admin mode fixes that, if you aren't already on an admin account. most people on vista are using admin accounts already, i imagine.

still, even vista without admin mode lets you write to certain folders. i don't know what those folders are, but if you find out, you can just use file_copy to those folders.
Logged

shrimp
Level 5
*****


View Profile WWW
« Reply #7 on: December 19, 2009, 02:04:27 AM »

Don't force people to be in Admin mode, for a start that instantly rules out most people trying to run it in at school/uni and maybe most non-technical job networks.

Dunno about GameMaker-specific issues, but the correct directory to put application ini files etc in is given by CSIDL_APPDATA (there are a lot of these for various folders, see here). That one (when passed into some Windows API function whose name might occur to me) will get you "C:\Users\<user>\AppData\" on this PC.

This post might give you some clues... gives examples in a few languages, and also the "wrong" way of getting it from an environment variable which might be a decent fall-back option in GM.

http://stackoverflow.com/questions/499095/best-way-of-getting-path-to-application-data-directory
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic