I was checking out the files in a old game called Warcraft III and saw that they had files with their own extension, for example,
How do you make your own file extension and run it?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
In short: you make your own file extension by applying whatever letters you want to the end of the file name. You run it by telling your OS what program should be called when you double-click on it.
A file extension is actually just the letters after the file, there is nothing magical about the extension. A lot of files I have made when I'm on my Linux machines I have forgotten to even put the file extension on.
That being said, in Windows the file extension is how Windows determines what the file is. If you change the file extension of an .mp3 for example to a .png Windows will think it is a picture when it tries to open it. What Windows does is it looks at the extension and sends the file to an appropriate program related to that file. so .mp3 gets sent to iTunes, .png gets sent to Paint, .html gets sent to Firefox/Chrome, and .docx gets sent to Word.
In terms of the creation of these files, they fall into two categories. There are plain text files (.html, .txt, .java, .py, .cpp, .config, .xml) and then there are binary data files (.exe, .mp3, .png) (well, and then there are mixes of binary and plain text like .docx, but they can be treated like binary files). When you are dealing with plain text files (it is plain text if Notepad can open it) it is very easy to do. Depending on your programming language you basically just open a file and read/write strings to the file. With binary files it gets a little more complicated, but the principle remains the same, you are reading/writing bytes from a file.
To make it so you can execute that type of file when you double-click on it is probably the hardest step depending on your programming language. If it is C or C++, you simply point Windows to your .exe and Windows sends the file you wish to open as the second argument in args to your program's main method. In Java or Python it is still doable, but you'll have to work out some sort of workaround to get Windows to open the run-time environment or interpreter and send the file argument to the program.
You will need to choose a programming language, then write a program which looks for files with an extension you have chossen. Those files must also be written so the program looking for them can read, understand and execute the code within.
Assuming since you're talking about Warcraft III you're on Windows. Also assuming you're not wanting to do this programatically (otherwise you would have asked on stackoverflow).
Save a file with your custom extension. Open the file in Windows Explorer and it will ask you how to open it. Choose "pick from list", select the program you want, and check "Always use the selected program to open this kind of file". Voila, you can now "run" files with your custom extension.
The .w3x extension is a map extension. Warcraft 3 doesn't run this extension, it's just map data.
They have their own algorithm / markup language to create these files and how to read them.
Well, just save the file under some name and that extension. "Running" it is a little more difficult, and depends partially on the OS as well.
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?