本文整理汇总了C++中parsePath函数的典型用法代码示例。如果您正苦于以下问题:C++ parsePath函数的具体用法?C++ parsePath怎么用?C++ parsePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parsePath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: parseHttp
void parseHttp() {
String line = Serial.readStringUntil('\n');
if (line.startsWith("Content-Length: ")) {
sscanf(line.c_str() + 16, "%d", &contentLength);
} else if (line.startsWith("GET")) {
method = GET;
path = parsePath(line);
} else if (line.startsWith("PUT")) {
method = PUT;
path = parsePath(line);
} else if (line == "\r") {
if (path.startsWith("/reset")) {
sendResponse(200);
setup();
} else if (path.startsWith("/sensors") && method == GET) {
getSensors();
} else if (path.startsWith("/leds") && (method == GET)) {
getLeds();
} else if (path.startsWith("/leds") && (method == PUT)) {
putLeds();
} else if (path.startsWith("/settings") && (method == GET)) {
getSettings();
} else if (path.startsWith("/settings") && (method == PUT)) {
putSettings();
} else {
sendResponse(404);
}
contentLength = 0;
}
}
开发者ID:grappendorf,项目名称:signal-tower,代码行数:30,代码来源:main.cpp
示例2: hw4_rename
/* rename - rename a file or directory
* Errors - path resolution, ENOENT, EINVAL, EEXIST
*
* ENOENT - source does not exist
* EEXIST - destination already exists
* EINVAL - source and destination are not in the same directory
*
* Note that this is a simplified version of the UNIX rename
* functionality - see 'man 2 rename' for full semantics. In
* particular, the full version can move across directories, replace a
* destination file, and replace an empty directory with a full one.
*/
static int hw4_rename(const char *src_path, const char *dst_path)
{
char *sub_src_path = (char*)calloc(16*44,sizeof(char));
char *sub_dst_path = (char*)calloc(16*44,sizeof(char));
char path1[20][44];
char path2[20][44];
int k = 0;
strcpy(sub_src_path, src_path);
strcpy(sub_dst_path, dst_path);
// save src path to path1
// save dst path to path2
while(1)
{
sub_src_path = strwrd(sub_src_path, path1[k], 44, " /");
sub_dst_path = strwrd(sub_dst_path, path2[k], 44, " /");
if (sub_src_path == NULL && sub_dst_path == NULL)
break;
if (sub_src_path == NULL || sub_dst_path == NULL)
return -EINVAL;
if (strcmp(path1[k], path2[k]) != 0)
return -EINVAL;
k++;
}
char *filename = (char*)malloc(sizeof(char)*44);
strcpy(filename, path2[k]);
int blk_num = super->root_dirent.start;
int current_blk_num;
// find the block and entry number of the src path
int entry = parsePath((void*)src_path, blk_num);
current_blk_num = new_current_blk_num;
// find the entry number of the dst path
int dst_entry = lookupEntry(filename, current_blk_num);
// check if the dst file is existed
if (dst_entry != -1)
return -EEXIST;
strcpy(directory[entry].name, filename);
directory[entry].mtime = time(NULL);
// write back
disk->ops->write(disk, current_blk_num*2, 2, (void*)directory);
free(filename);
free(sub_src_path);
free(sub_dst_path);
return 0;
}
开发者ID:carriercomm,项目名称:OS-Filesystem-C-Linux,代码行数:72,代码来源:homework.c
示例3: qMin
void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {
// TODO: missing ellipse element
if(!element.hasChildNodes()) {
double scale = qMin(qAbs(transform.m11()), qAbs(transform.m22()));
if (scale != 1 && transform.m21() == 0 && transform.m12() == 0) {
QString sw = element.attribute("stroke-width");
if (!sw.isEmpty()) {
bool ok;
double strokeWidth = sw.toDouble(&ok);
if (ok) {
element.setAttribute("stroke-width", QString::number(strokeWidth * scale));
}
}
}
// I'm a leaf node.
QString tag = element.nodeName().toLower();
if(tag == "path"){
QString data = element.attribute("d").trimmed();
if (!data.isEmpty()) {
const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
PathUserData pathUserData;
pathUserData.transform = transform;
if (parsePath(data, slot, pathUserData, this, true)) {
element.setAttribute("d", pathUserData.string);
}
}
}
开发者ID:Ipallis,项目名称:Fritzing,代码行数:31,代码来源:svgflattener.cpp
示例4: hw4_rmdir
/* rmdir - remove a directory
* Errors - path resolution, ENOENT, ENOTDIR, ENOTEMPTY
*/
static int hw4_rmdir(const char *path)
{
int blk_num = super->root_dirent.start;
int current_blk_num;
int i;
int entry = parsePath((void*)path, blk_num);
blk_num = new_blk_num;
current_blk_num = new_current_blk_num;
// check if it is a directory or not
if(directory[entry].isDir == 0)
return -ENOTDIR;
// check if the directory is empty
disk->ops->read(disk, blk_num * 2, 2, (void*)directory);
for(i = 0; i < 16; i++)
if(directory[i].valid)
return -ENOTEMPTY;
disk->ops->read(disk, current_blk_num * 2, 2, (void*)directory);
directory[entry].valid = 0;
fat[blk_num].inUse = 0;
// write the changes back
disk->ops->write(disk, current_blk_num * 2, 2, (void*)directory);
disk->ops->write(disk,2,8,(void*)fat);
return 0;
}
开发者ID:carriercomm,项目名称:OS-Filesystem-C-Linux,代码行数:36,代码来源:homework.c
示例5: EFS_DirOpen
// open a directory
DIR_ITER* EFS_DirOpen(struct _reent *r, DIR_ITER *dirState, const char *path) {
EFS_DirStruct *dir = (EFS_DirStruct*)dirState->dirStruct;
if(useDLDI && !nds_file)
return NULL;
// search for the directory in NitroFS
filematch = false;
searchmode = EFS_SEARCHDIR;
file_idpos = ~1;
file_idsize = 0;
// parse given path
parsePath(path, fileInNDS, true);
// are we trying to list the root path?
if(!strcmp(fileInNDS, "/"))
file_idpos = EFS_NITROROOTID;
else
ExtractDirectory("/", EFS_NITROROOTID);
if(file_idpos != ~1) {
dir->dir_id = file_idpos;
dir->curr_file_id = file_idsize;
dir->pos = ~1;
return dirState;
}
return NULL;
}
开发者ID:morukutsu,项目名称:ds-chewing-boy,代码行数:31,代码来源:efs_lib.c
示例6: fifo_output_init
static void *
fifo_output_init(G_GNUC_UNUSED const struct audio_format *audio_format,
const struct config_param *param,
GError **error)
{
struct fifo_data *fd;
char *value, *path;
value = config_dup_block_string(param, "path", NULL);
if (value == NULL) {
g_set_error(error, fifo_output_quark(), errno,
"No \"path\" parameter specified");
return NULL;
}
path = parsePath(value);
g_free(value);
if (!path) {
g_set_error(error, fifo_output_quark(), errno,
"Could not parse \"path\" parameter");
return NULL;
}
fd = fifo_data_new();
fd->path = path;
if (!fifo_open(fd, error)) {
fifo_data_free(fd);
return NULL;
}
return fd;
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpd,代码行数:33,代码来源:fifo_output_plugin.c
示例7: EFS_Open
// open a file
int EFS_Open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode) {
EFS_FileStruct *file = (EFS_FileStruct*)fileStruct;
if(useDLDI && !nds_file)
return -1;
// search for the file in NitroFS
filematch = false;
searchmode = EFS_SEARCHFILE;
file_idpos = 0;
file_idsize = 0;
// parse given path
parsePath(path, fileInNDS, false);
// search into NitroFS
ExtractDirectory("/", EFS_NITROROOTID);
if(file_idpos) {
file->start = file_idpos;
file->pos = file_idpos;
file->end = file_idpos + file_idsize;
return 0;
}
return -1;
}
开发者ID:morukutsu,项目名称:ds-chewing-boy,代码行数:28,代码来源:efs_lib.c
示例8: ln
static usize_t ln(String* args) {
String not_found = newstr("File not found", 16);
// get src file
String path = newstr(args->str, args->size);
if (path.size == 0) {
putraw("Source? ", 8);
get(&path);
}
File* src = fopen(path);
if (src == NULL) {
println(not_found);
return 1;
}
// get destination path & name
putraw("Target? ", 8);
String link_name;
get(&path); // reusing previously consumed `path`
Dir* parent;
parsePath(&path, &link_name);
parent = open_dir(&path, cwd);
if (parent == NULL) {
println(not_found);
return 1;
}
return new_file(&link_name, src, parent, t_LINK);
}
开发者ID:tvtritin,项目名称:msp430-os,代码行数:27,代码来源:bin.c
示例9: main
int main(int argc, char * argv[]) {
assert(argc == 3);
int fd = open(argv[1], O_RDWR);
assert(fd >= 0);
char ** fileNames = parsePath(argv[2]);
// Super * super = Super_(fd);
GroupDesc * groupDesc = Bgd_(fd);
// char buf[BLOCK_SIZE];
// for (int i = 0; i < 5; i++) {
// int ino = ialloc(fd);
// printf("allocated ino = %d\n", ino);
// }
// printBitmap(fd, (int) super->s_inodes_count,
// (int) groupDesc->bg_inode_bitmap);
// printBitmap(fd, (int) super->s_blocks_count,
// (int) groupDesc->bg_block_bitmap);
Inode * target = groupSearch(fd, fileNames, groupDesc);
if (target == NULL) {
printf("main: unable to find ");
printArray(fileNames);
} else {
inodeShow(fd, target);
}
close(fd);
return EXIT_SUCCESS;
}
开发者ID:yuchenhou,项目名称:systems-programming,代码行数:26,代码来源:lab6.c
示例10: line
void SvgFlattener::unRotateChild(QDomElement & element, QMatrix transform) {
// TODO: missing ellipse element
if(!element.hasChildNodes()) {
QString sw = element.attribute("stroke-width");
if (!sw.isEmpty()) {
bool ok;
double strokeWidth = sw.toDouble(&ok);
if (ok) {
QLineF line(0, 0, strokeWidth, 0);
QLineF newLine = transform.map(line);
element.setAttribute("stroke-width", newLine.length());
}
}
// I'm a leaf node.
QString tag = element.nodeName().toLower();
if(tag == "path"){
QString data = element.attribute("d").trimmed();
if (!data.isEmpty()) {
const char * slot = SLOT(rotateCommandSlot(QChar, bool, QList<double> &, void *));
PathUserData pathUserData;
pathUserData.transform = transform;
if (parsePath(data, slot, pathUserData, this, true)) {
element.setAttribute("d", pathUserData.string);
}
}
}
开发者ID:himanshuchoudhary,项目名称:cscope,代码行数:30,代码来源:svgflattener.cpp
示例11: prep
void Resty::prep(const string &method, const string &path, MethodHandler f) {
string mpath = path;
vector<string> names;
mRequestMap[method].push_back(parsePath(mpath, f) );
}
开发者ID:bertobot,项目名称:resty,代码行数:7,代码来源:Resty.cpp
示例12: parsePath
///-------------------------------------------------------------
bool CCommandLineParser::parseArgv( const char *const argv[ ] )
///-------------------------------------------------------------
{
return parsePath( argv ) &&
parseAmount( argv ) &&
parseMp3FileName( argv );
}
开发者ID:tim-oleksii,项目名称:mp3spammer,代码行数:8,代码来源:CCommandLineParser.cpp
示例13: clear
result_t Url::parse(exlib::string url, bool parseQueryString, bool slashesDenoteHost)
{
bool bHost;
clear();
m_slashes = false;
trimUrl(url, url);
const char* c_str = url.c_str();
bool hasHash = qstrchr(c_str, '#') != NULL;
if (!slashesDenoteHost && !hasHash && isUrlSlash(*c_str)) {
parsePath(c_str);
parseQuery(c_str);
parseHash(c_str);
if (parseQueryString) {
m_queryParsed = new HttpCollection();
m_queryParsed->parse(m_query);
}
return 0;
}
parseProtocol(c_str);
bHost = checkHost(c_str);
if (slashesDenoteHost || m_protocol.length() > 0 || bHost)
m_slashes = ((isUrlSlash(*c_str) && isUrlSlash(c_str[1])) && (m_protocol.length() <= 0 || m_protocol.compare("javascript:")));
if (m_protocol.compare("javascript:") && m_slashes) {
c_str += 2;
parseAuth(c_str);
parseHost(c_str);
}
parsePath(c_str);
parseQuery(c_str);
parseHash(c_str);
if (parseQueryString) {
m_queryParsed = new HttpCollection();
m_queryParsed->parse(m_query);
}
return 0;
}
开发者ID:asionius,项目名称:fibjs,代码行数:47,代码来源:Url.cpp
示例14: parsePath
String URI::getPathFile() const {
String dir, base, ext;
parsePath(mPath, dir, base, ext);
String pathFile = base;
if ( !ext.empty() )
pathFile += "." + ext;
return pathFile;
}
开发者ID:fire-archive,项目名称:OgreCollada,代码行数:8,代码来源:COLLADABUURI.cpp
示例15: if
void SvgFileSplitter::painterPathChild(QDomElement & element, QPainterPath & ppath)
{
// only partially implemented
if (element.nodeName().compare("circle") == 0) {
double cx = element.attribute("cx").toDouble();
double cy = element.attribute("cy").toDouble();
double r = element.attribute("r").toDouble();
double stroke = element.attribute("stroke-width").toDouble();
ppath.addEllipse(QRectF(cx - r - (stroke / 2), cy - r - (stroke / 2), (r * 2) + stroke, (r * 2) + stroke));
}
else if (element.nodeName().compare("line") == 0) {
/*
double x1 = element.attribute("x1").toDouble();
double y1 = element.attribute("y1").toDouble();
double x2 = element.attribute("x2").toDouble();
double y2 = element.attribute("y2").toDouble();
double stroke = element.attribute("stroke-width").toDouble();
// treat as parallel lines stroke width apart?
*/
}
else if (element.nodeName().compare("rect") == 0) {
double width = element.attribute("width").toDouble();
double height = element.attribute("height").toDouble();
double x = element.attribute("x").toDouble();
double y = element.attribute("y").toDouble();
double stroke = element.attribute("stroke-width").toDouble();
double rx = element.attribute("rx").toDouble();
double ry = element.attribute("ry").toDouble();
if (rx != 0 || ry != 0) {
ppath.addRoundedRect(x - (stroke / 2), y - (stroke / 2), width + stroke, height + stroke, rx, ry);
}
else {
ppath.addRect(x - (stroke / 2), y - (stroke / 2), width + stroke, height + stroke);
}
}
else if (element.nodeName().compare("ellipse") == 0) {
double cx = element.attribute("cx").toDouble();
double cy = element.attribute("cy").toDouble();
double rx = element.attribute("rx").toDouble();
double ry = element.attribute("ry").toDouble();
double stroke = element.attribute("stroke-width").toDouble();
ppath.addEllipse(QRectF(cx - rx - (stroke / 2), cy - ry - (stroke / 2), (rx * 2) + stroke, (ry * 2) + stroke));
}
else if (element.nodeName().compare("polygon") == 0 || element.nodeName().compare("polyline") == 0) {
QString data = element.attribute("points");
if (!data.isEmpty()) {
const char * slot = SLOT(painterPathCommandSlot(QChar, bool, QList<double> &, void *));
PathUserData pathUserData;
pathUserData.pathStarting = true;
pathUserData.painterPath = &ppath;
if (parsePath(data, slot, pathUserData, this, false)) {
}
}
}
开发者ID:DHaylock,项目名称:fritzing-app,代码行数:57,代码来源:svgfilesplitter.cpp
示例16: getScheme
void URL_Resolver::parseBase(string base){
getScheme(base);
if(schemeIsWeb){
getNET_LOC(base);
}
parsePath(base);
StringUtil::ToLower(SCHEME);
StringUtil::ToLower(NET_LOC);
}
开发者ID:itcropper,项目名称:WebCrawler,代码行数:10,代码来源:URL_Resolver.cpp
示例17: EFS_ChDir
// change current directory
int EFS_ChDir(struct _reent *r, const char *name) {
if(!name)
return -1;
// parse given path
parsePath(name, currPath, true);
return 0;
}
开发者ID:morukutsu,项目名称:ds-chewing-boy,代码行数:11,代码来源:efs_lib.c
示例18: parsePath
Path::Path(std::string path, std::string file, bool lastIsFolder)
{
#ifdef NIX
m_absolutePath = (path.size() > 0 && path[0] == '/');
#endif
parsePath(path, lastIsFolder);
if (lastIsFolder == false)
m_File = File(file);
}
开发者ID:CSRedRat,项目名称:desura-app,代码行数:11,代码来源:UtilFsPath.cpp
示例19: main
int main(int argc, char *argv[]) {
int i;
int pid, numChildren;
int status;
FILE *fid;
char cmdLine[MAX_LINE_LEN];
struct command_t command;
char *pathv[] = (char *) malloc(MAX_LINE_LEN);
parsePath(pathv); /* Get directory paths from PATH */
/* Read the command line parameters */
if ( argc != 2) {
fprintf(stderr, "Usage: launch <launch_set_filename>\n");
exit (0);
}
/* Open a file that contains a set of commands */
fid = fopen(argv[1], "r");
/* Process each command in the launch file */
numChildren = 0;
while(fgets(cmdLine, MAX_LINE_LEN, fid) != NULL) {
parseCommand(cmdLine, &command);
command.argv[command.argc] = NULL;
/* Create a child process to execute the command */
if((pid = fork()) == 0) {
/* Child executing command */
//execvp(command.name, command.argv); // must use execv instead
if(command.name[0] == '/') {
execv(command.name, command.argv);
} else {
execv(lookupPath(*pathv, command.argv), command.argv);
}
}
/* Parent continuing to the next command in the file */
numChildren++;
}
printf("\n\nlaunch: Launched %d commands\n", numChildren);
/* Terminate after all children have terminated */
for(i = 0; i < numChildren; i++) {
wait(&status);
/* Should free dynamic storage in command data structure */
}
printf("\n\nlaunch: Terminating successfully\n");
return 0;
}
开发者ID:stephenhu3,项目名称:os-projects,代码行数:53,代码来源:shellProgram.c
示例20: getPathsFromFile
static void getPathsFromFile(struct pfCompile *pfc, char *fileName)
/* Read in several fields of pfc from file. */
{
struct hash *hash = raReadSingle(fileName);
char *libPath;
pfc->cfgHash = hash;
pfc->cIncludeDir = mustFindSetting(hash, "cIncludeDir", fileName);
pfc->runtimeLib = mustFindSetting(hash, "runtimeLib", fileName);
pfc->jkwebLib = mustFindSetting(hash, "jkwebLib", fileName);
libPath = mustFindSetting(hash, "paraLibPath", fileName);
pfc->paraLibPath = parsePath(libPath);
}
开发者ID:bowhan,项目名称:kent,代码行数:12,代码来源:main.c
注:本文中的parsePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论