aidin36/tocc — pull request #94 by AnkitAggarwalPEC (2014-10-27 15:02:55+00:00)
Title: #83 CLI: No title set when importing a file from current directory

std::string get_filename_from_path(std::string path)
{
std::string filename;
//extract the file from path
int last_slash_index = path.rfind("/");
if(last_slash_index != std::string::npos)
{
filename = path.substr(last_slash_index + 1, path.length());
}
else
{
if(path.length()!=0)
{
filename=path;
}
}
//remove the file extension
int last_point_index = filename.rfind(".");
if(last_point_index != std::string::npos && last_point_index != 0)
{
filename = filename.substr(0, last_point_index);
}

return filename;
}
}