Jump to content
  • Advertisement
Sign in to follow this  
Solance

New file type?

This topic is 4886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How would i set up a new file type? and read,write to it? i need a file type ".config" that i could store things like Font=10, ect. how would i make this and read write from it?

Share this post


Link to post
Share on other sites
Advertisement
Learn about "text" mode file reading and writing for whatever language you are using.

By the way, that ".config" is only there to tell windows what to do with the file when you click on it, so you can change the name and extension to whatever you want as long as you read/write it correctly.

To make the file, use a basic text editor like notepad, vi, gedit, textpad, etc.

Share this post


Link to post
Share on other sites
Yep. There are only two types of files you work with. Text files are files that store text, like in a notepad or Word document. These are simple to read from and write to, but can be inefficient for storing large classes, and require you to parse the text to make something like a .config file usable in your program. You have to convert integers to text, and a user is more likely to screw up a text format file, because they *think* they know what they are doing.

You should learn about these first. They are easy to use and can be used for most purposes, at least for beginners.

The other kind of file format is binary. These store bytes of information. You can write numbers and such things directly, and can avoid parsing issues. These are much more complicated to learn, in my experiance. However, they are quite useful. I have a practical example in the following link, which took me a while to figure out how to do, and never generated much response :( Hope it helps.

If you are going to read/write to files, <fstream> is your best friend in C++.

[EDIT] Oh, yes... one other thing. File extensions have no neccesary correlation to what format they are in - again, text and binary are the ONLY two formats. They simply help specify what is stored in them, and how they should be used. For example, you can correlate .txt with a notepad file, and in Windows, when you double-click one, it launches notepad.exe. This functionality is build into Windows, and doesn't mean anything - in fact, you can load .txt files into your program easily, and you can change your Windows so .txt opens with Firefox, or MS Paint. It won't work for the latter, but if anyone cares to try, let me know what happens! :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!