#include <fstream>
#include <string>
#include <iostream>
#include <unistd.h>

using namespace std;


#define MAX_LENGTH 1000

int main(int argc, char* argv[])
{
    if (argc!=3)
    {
	cout << "Error! This program requires exactly two parameters:\n"
	        "input file and output file\n";
	
	return 0;
    }
    
    char buffer[MAX_LENGTH];
    string path = getcwd(buffer, MAX_LENGTH);
    ifstream input(argv[1]);
    ofstream output(argv[2]);
    
    while(true)
    {
	char c = input.get();

	if (input.eof())
	    break;
	
	if (!input)
	{
	    cout << "Fatal error. Icon can not be installed!\n";
	    
	    return 0;
	}
	    
	if (c=='$')
	    output << path;
	else
	    output << c;
    }
    
    return 0;
}
