void CWebSock::SetPaths(CModule* pModule, bool bIsTemplate) { m_Template.ClearPaths(); VCString vsDirs = GetDirs(pModule, bIsTemplate); for (size_t i = 0; i < vsDirs.size(); ++i) { m_Template.AppendPath(vsDirs[i]); } m_bPathsSet = true; }
CString CWebSock::FindTmpl(CModule* pModule, const CString& sName) { VCString vsDirs = GetDirs(pModule, true); CString sFile = pModule->GetModName() + "_" + sName; for (size_t i = 0; i < vsDirs.size(); ++i) { if (CFile::Exists(CDir::ChangeDir(vsDirs[i], sFile))) { m_Template.AppendPath(vsDirs[i]); return sFile; } } return sName; }
initFunction Init(){ T5_init(1, GetDirs()->save); INIT_OBJECT_TEMPLATES(ScriptFile); ADD_TO_PROTO(ScriptFile, "read", TS_fileRead); ADD_TO_PROTO(ScriptFile, "write", TS_fileWrite); ADD_TO_PROTO(ScriptFile, "flush", TS_fileFlush); ADD_TO_PROTO(ScriptFile, "close", TS_fileClose); // ADD_TO_PROTO(ScriptFile, "getNumKeys", TS_WSdrawWindow); // ADD_TO_PROTO(ScriptFile, "getKey", TS_WSdrawWindow); return (initFunction)"scriptfsT5"; }
v8Function TS_DoesFileExist(V8ARGS){ if(args.Length()<1){ THROWERROR("[scriptfs] TS_fileRead Error: Called with fewer than 2 arguments!\n"); } CHECK_ARG_STR(0); v8::String::Utf8Value str(args[0]); const char *path = (string(GetDirs()->save)+string(*str)).c_str(); FILE *filep = fopen(path, "r"); if(filep!=NULL){ fclose(filep); return v8::True(); } else{ return v8::False(); } }
int main(int argc, char **argv) { char CurDir[1024]; if (argc <= 1) { cout << "Please specify where to generate the config.h file." << endl; return 1; } chdir(argv[1]); getcwd(CurDir, 1024); if (!GetDirs()) return false; Out.open("config.h.temp"); Out << "#ifndef __CONFIG_H__" << endl << "#define __CONFIG_H__" << endl << endl; TestInc("jpeglib.h", NULL, "IL_NO_JPG", false); TestInc("libmng.h", NULL, "IL_NO_MNG", false); TestInc("png.h", NULL, "IL_NO_PNG", false); TestInc("tiff.h", NULL, "IL_NO_TIF", false); TestInc("lcms.h", "lcms", "IL_NO_LCMS", false); Out << endl; TestInc("gl.h", "gl", "ILUT_USE_OPENGL", true); TestInc("d3d8.h", NULL, "ILUT_USE_DIRECTX8",true); // Temporary fix for the SDL main() linker bug. //TestInc("sdl.h", NULL, "ILUT_USE_SDL", true); TestInc("windows.h", NULL, "ILUT_USE_WIN32", true); Out << endl << "#endif /* __CONFIG_H__ */" << endl; Out.close(); CleanUp(); chdir(CurDir); Compare(); return 0; }
bool SIDStil::SetBaseDir(PString pathToHVSC) { PString tempName; PDirectory dir; PList<DirList *> tempStilDirs, tempBugDirs; float tempStilVersion; // Temporary placeholder for STIL.txt's version number tempStilVersion = stilVersion; // Sanity check the length if (pathToHVSC.IsEmpty()) return (false); try { // Attempt to open STIL dir.SetDirectory(pathToHVSC); dir.Append("DOCUMENTS"); stilFile = new PCacheFile(dir.GetDirectory() + "STIL.txt", PFile::pModeRead | PFile::pModeShareRead); if (stilFile == NULL) throw PMemoryException(); // Attempt to open BUGList try { bugFile = new PCacheFile(dir.GetDirectory() + "BUGlist.txt", PFile::pModeRead | PFile::pModeShareRead); if (bugFile == NULL) throw PMemoryException(); } catch(PFileException e) { // This is not a critical error - some earlier versions of HVSC did // not have a BUGlist.txt file at all bugFile = NULL; } // This is necessary so the version number gets scanned in from the // new file, too stilVersion = 0.0f; if (GetDirs(stilFile, tempStilDirs, true) != true) throw PUserException(); if (bugFile != NULL) { if (GetDirs(bugFile, tempBugDirs, false) != true) { // This is not a critical error - it is possible that the // BUGlist.txt file has no entries in it at all (in fact, that's // good!) ; } } } catch(...) { // Close the files delete bugFile; bugFile = NULL; delete stilFile; stilFile = NULL; // Delete the directory lists DeleteDirList(tempStilDirs); DeleteDirList(tempBugDirs); // Copy back the original version stilVersion = tempStilVersion; return (false); } // Close the files stilFile->Close(); bugFile->Close(); // Now we can copy the stuff into private data. // NOTE: At this point, stilVersion should contain the new info! // // Remember the base directory baseDir = pathToHVSC; // First, delete whatever may have been there previously DeleteDirList(stilDirs); DeleteDirList(bugDirs); // Now proceed with copy CopyDirList(stilDirs, tempStilDirs); CopyDirList(bugDirs, tempBugDirs); // Clear the buffers (caches) entryBuf.MakeEmpty(); globalBuf.MakeEmpty(); bugBuf.MakeEmpty(); // Cleanup DeleteDirList(tempStilDirs); DeleteDirList(tempBugDirs); return (true); }
v8Function TS_GetFileList(V8ARGS){ v8::HandleScope TS_GetFileListscope; filehandle dir; filedata data; const char *directory; if(args.Length()>0){ CHECK_ARG_STR(0); v8::String::Utf8Value str(args[0]); if(strnlen(*str, 1022)<1){ directory = ""; } else{ if(DEBUG) printf("[scriptfs] GetFileList Info: The relative directory was %s\n", *str); char * tdir = (char *)malloc(strlen(*str)+1); if(DEBUG) printf("[scriptfs] GetFileList Info: tdir = %s\n", tdir); tdir = strcat(tdir, *str); char * ls = strrchr(tdir, '/'); if(ls[1]!='\0'){ strcat(tdir, "/"); } if(DEBUG) printf("[scriptfs] GetFileList Info: The directory as concated was %s\n", tdir); directory = STRDUP(tdir); free(tdir); } } else{ directory = ""; } const char ** filenames = NULL; int i = 0; const char *fulldir = STRDUP((string(GetDirs()->save).append(directory)).c_str()); if(DEBUG) printf("[scriptfs] GetFileList Info: The directory specified is %s\n", fulldir); #ifdef _WIN32 const char *fulldirlist = STRDUP((string(GetDirs()->save).append(directory)+"*.*").c_str()); DWORD attribs = ::GetFileAttributesA(fulldir); if ((attribs != INVALID_FILE_ATTRIBUTES) && (attribs & FILE_ATTRIBUTE_DIRECTORY)) { if(DEBUG) printf("[scriptfs] GetFileList Info: the directory was valid."); dir = FindFirstFile(fulldirlist, &data); if (dir!=INVALID_HANDLE_VALUE){ do{ #else if ((dir=opendir(GetDirs()->save))!=NULL){ while((data=readdir(dir))!=NULL){ #endif if((!ISDIRECTORY(data))&&(FILENAME(data)[0]!='.')){ filenames = (const char **)realloc(filenames, (i+1)*sizeof(const char *)); filenames[i] = STRDUP(FILENAME(data)); i++; } #ifdef _WIN32 } while(FindNextFile(dir, &data)); FindClose(dir); }//dir!=INVALID_HANDLE_VALUE free((void*)fulldirlist); }//attribs!=INVALID_FILE_ATTRIBUTES #if DEBUG else{ printf("[scriptfs] GetFileList Info: Directory does not exist.\n"); } #endif #else } closedir(dir); } #endif v8::Local<v8::Array> files = v8::Array::New(i); for(int e = 0; e<i; e++){ files->Set(e, v8::String::New(filenames[e])); free((void*)filenames[e]); } free(filenames); free((void*)fulldir); if(directory!=NULL){ free((void*)directory); } return TS_GetFileListscope.Close(files); }