void beginProgram (int argumentCount, char **argumentVector) { #if defined(GRUB_RUNTIME) #else /* at exit */ atexit(endProgram); #endif /* at exit */ initializeSystemObject(); prepareLocale(); if ((programPath = getProgramPath())) { registerProgramMemory("program-path", &programPath); } else { programPath = argumentVector[0]; } if (!isExplicitPath(programPath)) { char *path = findProgram(programPath); if (!path) path = testProgram(".", programPath); if (path) programPath = path; } if (isExplicitPath(programPath)) { #if defined(HAVE_REALPATH) && defined(PATH_MAX) if (!isAbsolutePath(programPath)) { char buffer[PATH_MAX]; char *path = realpath(programPath, buffer); if (path) { char *realPath = strdup(path); if (realPath) { programPath = realPath; } else { logMallocError(); } } else { logSystemError("realpath"); } } #endif /* defined(HAVE_REALPATH) && defined(PATH_MAX) */ if (!isAbsolutePath(programPath)) { char *directory; if ((directory = getWorkingDirectory())) { char *path; if ((path = makePath(directory, programPath))) programPath = path; free(directory); } } } programName = locatePathName(programPath); pushLogPrefix(programName); }
int enableSpeechInput (const char *name) { const char *directory; onProgramExit("speech-input", exitSpeechInput, NULL); #if defined(__MINGW32__) directory = "//./pipe"; #else /* set speech input directory */ directory = "."; #endif /* set speech input directory */ if ((speechInputPath = makePath(directory, name))) { #if defined(__MINGW32__) if ((speechInputHandle = CreateNamedPipe(speechInputPath, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE|PIPE_READMODE_MESSAGE|PIPE_NOWAIT, 1, 0, 0, 0, NULL)) != INVALID_HANDLE_VALUE) { logMessage(LOG_DEBUG, "speech input pipe created: %s: handle=%u", speechInputPath, (unsigned)speechInputHandle); return 1; } else { logWindowsSystemError("CreateNamedPipe"); } #elif defined(S_ISFIFO) int result = mkfifo(speechInputPath, 0); if ((result == -1) && (errno == EEXIST)) { struct stat fifo; if ((lstat(speechInputPath, &fifo) != -1) && S_ISFIFO(fifo.st_mode)) result = 0; } if (result != -1) { chmod(speechInputPath, S_IRUSR|S_IWUSR|S_IWGRP|S_IWOTH); if ((speechInputDescriptor = open(speechInputPath, O_RDONLY|O_NONBLOCK)) != -1) { logMessage(LOG_DEBUG, "speech input FIFO created: %s: fd=%d", speechInputPath, speechInputDescriptor); return 1; } else { logMessage(LOG_ERR, "cannot open speech input FIFO: %s: %s", speechInputPath, strerror(errno)); } unlink(speechInputPath); } else { logMessage(LOG_ERR, "cannot create speech input FIFO: %s: %s", speechInputPath, strerror(errno)); } #endif /* enable speech input */ free(speechInputPath); speechInputPath = NULL; } return 0; }
u32 SimpleXP3::itemToFile(SIndexItem* pItem, const s8* basePath) { if (!pItem) return XP3_INVALIDARGUMENT; s8 fullPath[512]; s8* fileName = pItem->fileName; u32 lenBase = (basePath ? strlen(basePath) : 0); if (!basePath) { snprintf(fullPath,sizeof(fullPath),"%s",fileName); } else { u32 slashes = (basePath[lenBase-1] == '/') ? 1 : 0; if (pItem->fileName[0] == '/') ++slashes; if (slashes > 0) { if (slashes == 2) ++fileName; snprintf(fullPath,sizeof(fullPath),"%s%s",basePath,fileName); } else snprintf(fullPath,sizeof(fullPath),"%s/%s",basePath,fileName); } u32 lastSlash = 0; for (lastSlash = strlen(fullPath); lastSlash > 0; --lastSlash) { if (fullPath[lastSlash] == '/') break; } if (lastSlash == 0) return XP3_INVALIDARGUMENT; fullPath[lastSlash] = 0; if (makePath(fullPath)) return XP3_FILESYSERR; fullPath[lastSlash] = '/'; unique_file f = unique_file(fopen(fullPath,"wb")); if (!f.get()) return XP3_IOERR; unique_buffer<u8> fileBuffer = unique_buffer<u8>(pItem->sizeUncompressed); u32 ret = itemToMemory(pItem,fileBuffer.get()); if (ret != XP3_OK) return ret; WRITE_ARRAY_DYN(f.get(),fileBuffer.get(),pItem->sizeUncompressed); return XP3_OK; }
void RecursiveBacktrackerMaze::generate() { m_visited = QVector< QVector<bool> >(columns(), QVector<bool>(rows())); QPoint start(0, randomInt(rows())); m_visited[start.x()][start.y()] = true; makePath(start); m_visited.clear(); }
void traversal(TreeNode * node) { if (!node) return; path.push_back(node->val); // add to the pass if (!node->left && !node->right) ans.push_back(makePath()); traversal(node->left); traversal(node->right); path.pop_back(); // delete from the pass }
void runIpmgmtd(void) { pid_t pid; int status; int tmplfd; tmplfd = init_template(0); if ((pid = fork()) == -1) { fatal(ERR_FORK_FAILED, "fork() failed: %s\n", strerror(errno)); } if (pid == 0) { /* child */ char cmd[MAXPATHLEN]; char *const argv[] = { "ipmgmtd", NULL }; char *const envp[] = { "SMF_FMRI=svc:/network/ip-interface-management:default", NULL }; (void) ct_tmpl_clear(tmplfd); (void) close(tmplfd); makePath(IPMGMTD, cmd, sizeof (cmd)); execve(cmd, argv, envp); fatal(ERR_EXEC_FAILED, "execve(%s) failed: %s\n", cmd, strerror(errno)); } /* parent */ (void) ct_tmpl_clear(tmplfd); (void) close(tmplfd); dlog("INFO started ipmgmtd[%d]\n", (int)pid); while (wait(&status) != pid) { /* EMPTY */; } if (WIFEXITED(status)) { dlog("INFO ipmgmtd[%d] exited: %d\n", (int)pid, WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { fatal(ERR_IPMGMTD_DIED, "ipmgmtd[%d] died on signal: %d\n", (int)pid, WTERMSIG(status)); } else { fatal(ERR_IPMGMTD_CRASHED, "ipmgmtd[%d] failed in unknown way\n", (int)pid); } }
bool CreateTextureAndBitmask(sf::Texture &LoadInto, const std::string& Filename) { sf::Image img; if (!img.loadFromFile(makePath(Filename))) return false; if (!LoadInto.loadFromImage(img)) return false; Bitmasks.CreateMask(&LoadInto, img); return true; }
bool side::enter() { if (filesPath.size() < 2 && !(_stricmp(files[indexFile].name, ".."))) return false; else if (!(_stricmp(files[indexFile].name, ".."))) //.. { string tName(filesPath.back()); filesPath.pop_back(); makePath(); if (!fillFiles()) throw string("Can't read the directory: " + path); indexFile = getIndexByNameInCurrent(tName); if (indexFile >= side::countFiles) // не вміщається в першу (значить хз :) десь посерединці поставимо :)) { indexRow = 10; upIndexFile = indexFile - 10; } else // ваміщається в перший комлект { upIndexFile = 0; indexRow = indexFile; } show(); writePath(); return true; } else if ((_stricmp(files[indexFile].name, "..")) && !(files[indexFile].attrib & _A_SUBDIR)) return false; else // not .. but folder { filesPath.emplace_back(files[indexFile].name); makePath(); if (!fillFiles()) throw string("Can't read the directory: " + path); clearIndex(); show(); writePath(); return true; } }
CDWordArray * GetRegistryDWordArray(HKEY root, const CString &var) { CString path; DWORD len; DWORD type; path.LoadString(IDS_PROGRAM_ROOT); CString name; makePath(path, var, name); HKEY key; LONG result = ::RegOpenKey(root, path, &key); if(result != ERROR_SUCCESS) { /* failed */ ::SetLastError(result); return NULL; } /* failed */ result = ::RegQueryValueEx(key, name, 0, &type, NULL, &len); if(result != ERROR_SUCCESS) { /* failed */ ::SetLastError((DWORD)result); ::RegCloseKey(key); return NULL; } /* failed */ CDWordArray * data = new CDWordArray; DWORD count = len / sizeof(DWORD); data->SetSize((int)count); // preallocate the array data result = ::RegQueryValueEx(key, name, 0, &type, (LPBYTE)&(*data)[0], &len); if(result != ERROR_SUCCESS) { /* failed */ ::RegCloseKey(key); ::SetLastError((DWORD)result); delete data; return NULL; } /* failed */ ::RegCloseKey(key); if(type != REG_BINARY) { /* wrong type */ ::SetLastError(ERROR_INVALID_DATA); delete data; return NULL; } /* wrong type */ return data; }
BOOL SetRegistryFont(HKEY root, const CString & var, const LOGFONT * f) { CString path; path.LoadString(IDS_PROGRAM_ROOT); CString name; makePath(path, var, name); HKEY key; LONG result = makeKey(root, path, &key); if(result != ERROR_SUCCESS) return FALSE; HKEY rkey; DWORD disp; if(f == NULL) { /* delete key */ result = SHDeleteKey(key, name); // deletes key and all subkeys ASSERT(result == ERROR_SUCCESS); // better error reporting later ::RegCloseKey(key); return TRUE; } /* delete key */ result = ::RegCreateKeyEx(key, name, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &rkey, &disp); if(result != ERROR_SUCCESS) return FALSE; // Note that we save only a subset of the LOGFONT information // Note also that we use constant names from the LOGFONT structure // so we don't load them from the resource strings #define RegSetFontValue(field) ::RegSetValueEx(rkey, _T(#field), 0, \ sizeof(f->field) == sizeof(DWORD) ? REG_DWORD : REG_BINARY, \ (LPBYTE)&f->field, sizeof(f->field)) VERIFY((result = RegSetFontValue(lfHeight)) == ERROR_SUCCESS); VERIFY((result = RegSetFontValue(lfWeight)) == ERROR_SUCCESS); VERIFY((result = RegSetFontValue(lfItalic)) == ERROR_SUCCESS); VERIFY((result = RegSetFontValue(lfUnderline)) == ERROR_SUCCESS); VERIFY((result = RegSetFontValue(lfStrikeOut)) == ERROR_SUCCESS); result = ::RegSetValueEx(rkey, _T("lfFaceName"), 0, REG_SZ, (LPBYTE)f->lfFaceName, lstrlen(f->lfFaceName) + 1); ::RegCloseKey(rkey); ::RegCloseKey(key); return TRUE; // assume success } // SetRegistryFont
int Game::LoadSFX() { if (!m_soundBuffers[0].loadFromFile(makePath("Sounds/laser.ogg"))) return -1; m_soundsLaser[0].setBuffer(m_soundBuffers[0]); m_soundsLaser[0].setVolume(DEFAULT_SFX_VOLUME * m_SFX_Activated); //soundsSwitch.setVolume(DEFAULT_SFX_VOLUME * m_SFX_Activated); return 0; }
char * getDevicePath (const char *device) { const char *directory = getDeviceDirectory(); #ifdef ALLOW_DOS_DEVICE_NAMES if (isDosDevice(device, NULL)) { //directory = NULL; } #endif /* ALLOW_DOS_DEVICE_NAMES */ return makePath(directory, device); }
char * makeFilePath (const char *directory, const char *name, const char *extension) { char *path = NULL; char *file = ensureFileExtension(name, extension); if (file) { path = makePath(directory, file); free(file); } return path; }
static char * testProgram (const char *directory, const char *name) { char *path; if ((path = makePath(directory, name))) { if (testProgramPath(path)) return path; free(path); } return NULL; }
char * makeTextTablePath (const char *directory, const char *name) { char *subdirectory = makePath(directory, TEXT_TABLES_SUBDIRECTORY); if (subdirectory) { char *file = makeFilePath(subdirectory, name, TEXT_TABLE_EXTENSION); free(subdirectory); if (file) return file; } return NULL; }
void makeStar(int n, edgefn ef) { int i; if (n < 3) { fprintf(stderr, "Warning: degenerate star of %d vertices\n", n); makePath(n, ef); return; } for (i = 2; i <= n; i++) ef (1, i); }
void makeLotPath(int lotNr,char folder[],char subname[]) { char path[PATH_MAX]; GetFilPathForLot(path,lotNr,subname); strcat(path,"/"); strcat(path,folder); makePath(path); }
BOOL GetRegistryKey(HKEY root, const CString & keyname, HKEY & key) { CString path; path.LoadString(IDS_PROGRAM_ROOT); CString name; makePath(path, keyname, name); path += _T("\\"); path += name; LONG result = makeKey(root, path, &key); return result == ERROR_SUCCESS; } // GetRegistryKey
void SVDependTable::changePath() { if(m_pHideEdit && !m_pHideEdit->text().empty() && m_pHideEdit->text() != "-2") { if(m_pPath) m_pPath->setText(makePath(m_pHideEdit->text())); } else { if(m_pPath) m_pPath->setText(SVResString::getResString("IDS_Friendless")); } }
const char * getOverrideDirectory (void) { static const char *directory = NULL; if (!directory) { static const char subdirectory[] = "." PACKAGE_NAME; { char *homeDirectory = getHomeDirectory(); if (homeDirectory) { directory = makePath(homeDirectory, subdirectory); free(homeDirectory); if (directory) goto gotDirectory; } } { char *workingDirectory = getWorkingDirectory(); if (workingDirectory) { directory = makePath(workingDirectory, subdirectory); free(workingDirectory); if (directory) goto gotDirectory; } } directory = ""; logMessage(LOG_WARNING, "no override directory"); goto ready; gotDirectory: logMessage(LOG_INFO, "Override Directory: %s", directory); registerProgramMemory("override-directory", &directory); } ready: return *directory? directory: NULL; }
/** * This function reads in the image list file. It then * takes the image filenames and reads in every file. * * @returns A Matrix containing all of the images */ Matrix readImages(char *imageNamesFile, char *imageDirectory, int *numPixels, int *numImages, int *numSubjects, ImageList **srt) { int i; Matrix images; ImageList *subject, *replicate; DEBUG(1, "Reading training file names from file"); *srt = getImageNames(imageNamesFile, numImages); DEBUG_CHECK(*srt, "Error: header no imagenames found in file image list file"); /* Automatically determine number of pixels in images */ DEBUG(1, "Autodetecting number of pixels, i.e. vector length based on the size of image 0."); *numPixels = autoFileLength(makePath(imageDirectory, (*srt)->filename)); DEBUG_INT(1, "Vector length", * numPixels); DEBUG_CHECK(*numPixels > 0, "Error positive value required for a Vector Length"); /* Images stored in the columns of a matrix */ DEBUG(1, "Allocating image matrix"); images = makeMatrix(*numPixels, *numImages); i = 0; (*numSubjects) = 0; for (subject = *srt; subject; subject = subject->next_subject) { for (replicate = subject; replicate; replicate = replicate->next_replicate) { if (debuglevel > 0) printf("%s ", replicate->filename); replicate->imageIndex = i; readFile(makePath(imageDirectory, replicate->filename), i++, images); } if (debuglevel > 0) printf("\n"); (*numSubjects)++; } return images; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 函数 setDepend // 说明 设置依靠 // 参数 string &szDepend, 依靠 // 返回 无 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// void SVDependTable::setDepend(string &szDepend) { // 暂时无法进行设置 // 需等待树的完成 if(m_pHideEdit && !szDepend.empty()) { m_szOldDependID = szDepend; if(m_szOldDependID.empty()) m_szOldDependID = "-2"; m_pHideEdit->setText(szDepend); if(m_pPath) m_pPath->setText(makePath(m_pHideEdit->text())); } }
void makeCircle(int n, edgefn ef) { int i; if (n < 3) { fprintf(stderr, "Warning: degenerate circle of %d vertices\n", n); makePath(n, ef); return; } for (i = 1; i < n; i++) ef ( i, i + 1); ef (1, n); }
Path::Path(const JSONCPP_STRING& path, const PathArgument& a1, const PathArgument& a2, const PathArgument& a3, const PathArgument& a4, const PathArgument& a5) { InArgs in; in.push_back(&a1); in.push_back(&a2); in.push_back(&a3); in.push_back(&a4); in.push_back(&a5); makePath(path, in); }
Path::Path(const std::string &path, const PathArgument &a1, const PathArgument &a2, const PathArgument &a3, const PathArgument &a4, const PathArgument &a5) { InArgs in; in.push_back(&a1); in.push_back(&a2); in.push_back(&a3); in.push_back(&a4); in.push_back(&a5); makePath(path, in); }
NamedPipeObject * newNamedPipeObject (const char *name, NamedPipeInputCallback *callback, void *data) { NamedPipeObject *obj; if ((obj = malloc(sizeof(*obj)))) { memset(obj, 0, sizeof(*obj)); obj->callback = callback; obj->data = data; obj->createPipe = NULL; obj->monitorPipe = monitorInput; obj->resetPipe = NULL; obj->releaseResources = NULL; setNamedPipeMethods(obj); initializeHostPath(obj); initializeInputDescriptor(obj); initializeInputMonitor(obj); { const char *directory = getNamedPipeDirectory(); obj->host.path = directory? makePath(directory, name): NULL; } if (obj->host.path) { if (!obj->createPipe) { logUnsupportedOperation("create named pipe"); } else if (obj->createPipe(obj)) { if (!obj->monitorPipe) { logUnsupportedOperation("monitor named pipe"); } else if (obj->monitorPipe(obj)) { return obj; } closeInputDescriptor(obj); removePipe(obj); } deallocateHostPath(obj); } free(obj); } else { logMallocError(); } return NULL; }
void CubeAnim::getPaths(const char * path) { DIR *mydir; struct dirent *currentdir; mydir = opendir(path); _paths.clear(); if (mydir != NULL) while ((currentdir = readdir(mydir)) != NULL) { if (checkName(currentdir->d_name) && checkName(currentdir->d_name)) _paths.push_back(makePath(currentdir->d_name, path)); } }
void Application::saveSRam(const char* romName) { char path[MAX_PATH]; makePath(_sramDir, path); sprintf(path, "%s.srm", path); LOGD("Saving SRAM: %s", path); FILE *f = fopen(path,"wb"); if (f!= NULL) { fwrite(sram.sram,0x10000,1, f); fclose(f); } }
/* Read the current settings, load them into the UI and then display it */ void Preferences::loadAndShow( ) { QSettings settings("MakingThings", "mcbuilder"); workspaceEdit->setText(QDir::toNativeSeparators(workspace())); makePathEdit->setText(QDir::toNativeSeparators(makePath())); toolsPathEdit->setText(QDir::toNativeSeparators(toolsPath())); sam7PathEdit->setText(QDir::toNativeSeparators(sam7Path())); Qt::CheckState state = (settings.value("checkForUpdates", true).toBool()) ? Qt::Checked : Qt::Unchecked; updaterBox->setCheckState(state); fontBox->setText(QString("%1, %2pt").arg(currentFont.family()).arg(currentFont.pointSize())); tabWidth->setText(QString::number(settings.value("tabWidth", DEFAULT_TAB_WIDTH).toInt())); show( ); }
void Application::loadSRam(const char* romName) { char path[MAX_PATH]; makePath(_sramDir, path); sprintf(path, "%s.srm", path); LOGD("Loading SRAM: %s", path); FILE *f = fopen(path,"rb"); if (f != NULL) { fread(sram.sram,0x10000,1, f); sram.crc = crc32(0, sram.sram, 0x10000); fclose(f); } }