fstream starting location (from environment to C:\\)

Started by
7 comments, last by jeroenb 12 years, 3 months ago
I want to test if the user is using a mom-administrative account, like at school, and i need to test if a sensitive area (like C:\\system\) kind of directory is write-able to. i have looked around, and this seams to be the best method. now that i know what im going to do, i need to know how to use fstream from the directory C:\\ instead of where the application directory is. what do i need to do?
Advertisement
You'll just need to provide a full path instead of a relative path, the OS should take care of the rest smile.png

'system32' will look in the directory of your application
'C:/system32' wont look in the directory of your application

P.S Yes, you can use / instead of \\ to describe a path in Windows D.S
Those who can do, do; those who can't do, do teach.
Thanks! it works, but for some reason i cant write to the C:/Windows/System32 directory...
As in, i can see the file in "C:/" but not in "C:/Windows/System32/"
You need to run the application as an admin to access system32. If you open explorer and attempts to access those directories you should get a UAC confirmation box - which means that you're actually accessing the data with permission from the admin.

If you run the application as admin (right click, preferences, ..., run as admin) it should work. You should also be able to request those permissions from the system.
Those who can do, do; those who can't do, do teach.
This sounds like a bad way to check if the user is an admin.

This sounds like a good way.
Why do you care if the user is an administrator?
XD well for my game, i usually show people at school. it has some reaslistic 2D images of guns... XD
When i was trying to download OpenAL, i saw that you cant access a specific folder... so thats how i thought of it.

I dont think i will be using this though, but its good for other things. ;P
I don't understand. What does being an administrator do with using OpenAL?

If you did need to do an administrative task to run the game, the normal solution is to provide an installer that can be run as an administrator if necessary. But do check if it is actually necessary, it is really bad to try to put shit into the user's system directories. Just think, what if two programs try this, but disagree on the contents of the file they are writing?
I agree that for a game you should not need administrative rights. When it runs on a windows platform you can use the Windows API to query standard directories where you can write the save games, etc. and where the system32 and program files directories are. I am pretty sure that Linux has similar methods. As Rip-off mentioned for an installer it is allowed to ask for admin rights if you install to for example the program files directory.

So, better try not to use it: users don't like the boxes.

Crafter 2D: the open source 2D game framework

?Github: https://github.com/crafter2d/crafter2d
Twitter: [twitter]crafter_2d[/twitter]

This topic is closed to new replies.

Advertisement