#include "SourceView.h"#include <iostream>#include <fstream>#include <sstream>#include <boost/algorithm/string.hpp>#include <boost/filesystem/operations.hpp>#include <boost/filesystem/convenience.hpp>#include <Wt/WApplication>#include <Wt/WText>#include <Wt/WImage>Go to the source code of this file.
Functions | |
| std::string | tempFileName () |
| std::string | getLanguageFromFileExtension (const std::string &fileName) |
| std::string | readFileToString (const std::string &fileName) |
| std::string getLanguageFromFileExtension | ( | const std::string & | fileName | ) |
Definition at line 61 of file SourceView.C.
00062 { 00063 if (boost::iends_with(fileName, ".h") 00064 || boost::iends_with(fileName, ".C") 00065 || boost::iends_with(fileName, ".cpp")) 00066 return "cpp"; 00067 else if (boost::iends_with(fileName, ".xml")) 00068 return "xml"; 00069 else if (boost::iends_with(fileName, ".html")) 00070 return "html"; 00071 else if (boost::iends_with(fileName, ".java")) 00072 return "java"; 00073 else if (boost::iends_with(fileName, ".css")) 00074 return "css"; 00075 else 00076 return std::string(); 00077 }
| std::string readFileToString | ( | const std::string & | fileName | ) |
Definition at line 79 of file SourceView.C.
00080 { 00081 std::size_t outputFileSize = (std::size_t)fs::file_size(fileName); 00082 std::fstream file (fileName.c_str(), std::ios::in | std::ios::binary); 00083 char* memblock = new char [outputFileSize]; 00084 file.read(memblock, outputFileSize); 00085 file.close(); 00086 std::string data = std::string(memblock, outputFileSize); 00087 delete [] memblock; 00088 return data; 00089 }
| std::string tempFileName | ( | ) |
Definition at line 46 of file SourceView.C.
00047 { 00048 #ifndef WIN32 00049 char spool[20]; 00050 strcpy(spool, "/tmp/wtXXXXXX"); 00051 00052 int i = mkstemp(spool); 00053 close(i); 00054 #else 00055 char spool[2 * L_tmpnam]; 00056 tmpnam(spool); 00057 #endif 00058 return std::string(spool); 00059 }
1.5.6