I am writing an assembler for a simulated computer system(H1), that we use in class. The assembler has to create a list file with a bunch of info in it. I am just about done, I'm just writing error code. If I detect one of several errors, I need to exit. As part of that process I want to delete the partially written *.lst file, and I'm getting a permission denied error. Here is the code in question.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// if symbol table gets too large, we have to abort
if (symbol_table_pointer >= SYMBOL_TABLE_SIZE)
{
cout << endl << endl;
cout << "Too many symbols, maximum number is " << SYMBOL_TABLE_SIZE << endl;
cout << "Cleaning up files and Aborting...";
cout << endl << endl;
list.close();
if( remove( listFilePath.c_str() ) != 0 )
perror( "Error deleting list file" );
else
puts( "list file successfully deleted" );
system("pause");
return(1);
}
I get "Error deleting list file: Permission Denied"
Am I doing something wrong, or is this an OS thing? Its Win 7, and I'm running Visual Studio 2008. (the user that I'm logged in has full permissions on the folder in question, and i can delete the file manually)