本文整理汇总了C++中FileName::path方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::path方法的具体用法?C++ FileName::path怎么用?C++ FileName::path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dir_copy
//-------------------------------------------------------------------
// FileName::dir_copy
//-------------------------------------------------------------------
void FileName::dir_copy(const String &strDest, bool bCreateDir, mode_t modeDir, uid_t uid, gid_t gid) throw( Exception )
{
FileName fnDst;
// Create destination path
fnDst.set(strDest);
fnDst.mkdir(modeDir, uid, gid);
if( bCreateDir )
{
// Create source directory name inside destination path
fnDst.set(strDest + dir_name() + SEP_PATH);
fnDst.mkdir(modeDir, uid, gid);
}
if( !fnDst.is_path_name() )
throw BadPathException(PSZ(String::str_format(ERR_BAD_DEST_PATH, PSZ(fnDst.full_name()))),
"FileName::dir_copy");
// Recursively copying sub-directories
FileEnum dirEnum(full_name(), FileEnum::ENUM_DIR);
while( dirEnum.find() )
dirEnum.dir_copy(fnDst.path(), true, modeDir, uid, gid);
// Copying directory files
FileEnum fileEnum(full_name(), FileEnum::ENUM_FILE);
while( fileEnum.find() )
// Copy with metadata
fileEnum.copy(fnDst.path(), true);
}
示例2: main
/* main function in embree namespace */
int main(int argc, char** argv)
{
/* for best performance set FTZ and DAZ flags in MXCSR control and status register */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
/* create stream for parsing */
Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv));
/* parse command line */
parseCommandLine(stream, FileName());
/* load default scene if none specified */
if (filename.ext() == "") {
FileName file = FileName::executableFolder() + FileName("models/cornell_box.ecs");
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* configure number of threads */
if (g_numThreads)
g_rtcore += ",threads=" + std::to_string((long long)g_numThreads);
if (g_numBenchmarkFrames)
g_rtcore += ",benchmark=1";
g_rtcore += g_subdiv_mode;
/* load scene */
if (strlwr(filename.ext()) == std::string("obj")) {
g_scene->add(loadOBJ(filename,g_subdiv_mode != ""));
}
else if (strlwr(filename.ext()) == std::string("xml")) {
g_scene->add(loadXML(filename,one));
}
else if (filename.ext() != "")
THROW_RUNTIME_ERROR("invalid scene type: "+strlwr(filename.ext()));
/* initialize ray tracing core */
init(g_rtcore.c_str());
/* send model */
g_obj_scene.add(g_scene.dynamicCast<SceneGraph::Node>(),g_instancing_mode);
g_scene = nullptr;
set_scene(&g_obj_scene);
/* benchmark mode */
if (g_numBenchmarkFrames)
renderBenchmark(outFilename);
/* render to disk */
if (outFilename.str() != "")
renderToFile(outFilename);
/* interactive mode */
if (g_interactive) {
initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen);
enterWindowRunLoop(g_anim_mode);
}
return 0;
}
示例3: openLibrary
/* opens a shared library */
lib_t openLibrary(const std::string& file)
{
std::string fullName = file+".dll";
FileName executable = getExecutableFileName();
HANDLE handle = LoadLibrary((executable.path() + fullName).c_str());
return lib_t(handle);
}
示例4: parseCommandLine
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
while (true)
{
std::string tag = cin->getString();
if (tag == "") return;
/* parse command line parameters from a file */
if (tag == "-c") {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* load OBJ model*/
else if (tag == "-i") {
filename = path + cin->getFileName();
}
/* ambient light source */
else if (tag == "-ambientlight") {
g_ambientLightIntensity = cin->getVector3f();
}
/* point light source */
else if (tag == "-pointlight") {
g_pointLightPosition = cin->getVector3f();
g_pointLightIntensity = cin->getVector3f();
}
/* parse camera parameters */
else if (tag == "-vp") g_camera.from = cin->getVector3f();
else if (tag == "-vi") g_camera.to = cin->getVector3f();
else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVector3f();
else if (tag == "-vu") g_camera.up = cin->getVector3f();
else if (tag == "-fov") g_camera.fov = cin->getFloat();
/* frame buffer size */
else if (tag == "-size") {
g_width = cin->getInt();
g_height = cin->getInt();
}
/* full screen mode */
else if (tag == "-fullscreen")
g_fullscreen = true;
/*! enable verbose output mode */
else if (tag == "-verbose") {
g_verbose = 1;
}
/* skip unknown command line parameter */
else {
std::cerr << "unknown command line parameter: " << tag << " ";
while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
std::cerr << std::endl;
}
}
}
示例5: postParseCommandLine
void postParseCommandLine()
{
/* load default scene if none specified */
if (scene->size() == 0 && sceneFilename.ext() == "") {
FileName file = FileName::executableFolder() + FileName("models/cornell_box.ecs");
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
}
示例6: parseCommandLine
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
while (true)
{
std::string tag = cin->getString();
if (tag == "") return;
/* parse command line parameters from a file */
else if (tag == "-c") {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* load OBJ model*/
else if (tag == "-i") {
filename = path + cin->getFileName();
}
/* parse camera parameters */
else if (tag == "-vp") g_camera.from = cin->getVec3fa();
else if (tag == "-vi") g_camera.to = cin->getVec3fa();
else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
else if (tag == "-vu") g_camera.up = cin->getVec3fa();
else if (tag == "-fov") g_camera.fov = cin->getFloat();
/* frame buffer size */
else if (tag == "-size") {
g_width = cin->getInt();
g_height = cin->getInt();
}
/* full screen mode */
else if (tag == "-fullscreen")
g_fullscreen = true;
/* rtcore configuration */
else if (tag == "-rtcore")
g_rtcore = cin->getString();
/* number of threads to use */
else if (tag == "-threads")
g_numThreads = cin->getInt();
/* skip unknown command line parameter */
else {
std::cerr << "unknown command line parameter: " << tag << " ";
while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
std::cerr << std::endl;
}
}
}
示例7: loadKeyFrameAnimation
void loadKeyFrameAnimation(FileName &fileName)
{
PRINT(fileName);
std::ifstream cin;
cin.open(fileName.c_str());
if (!cin.is_open()) {
std::cerr << "cannot open " << fileName.str() << std::endl;
return;
}
FileName path;
path = fileName.path();
char line[10000];
memset(line, 0, sizeof(line));
int cur = 0;
while (cin.peek() != -1)
{
/* load next multiline */
char* pline = line;
while (true) {
cin.getline(pline, sizeof(line) - (pline - line) - 16, '\n');
ssize_t last = strlen(pline) - 1;
if (last < 0 || pline[last] != '\\') break;
pline += last;
*pline++ = ' ';
}
OBJScene *scene = new OBJScene;
FileName keyframe = path + FileName(line);
loadOBJ(keyframe,one,*scene,true);
PRINT(keyframe);
if (g_obj_scene.subdiv.size() != scene->subdiv.size())
FATAL("#subdiv meshes differ");
for (size_t i=0;i<g_obj_scene.subdiv.size();i++)
if (g_obj_scene.subdiv[i]->positions.size() != scene->subdiv[i]->positions.size())
FATAL("#positions differ");
g_keyframes.push_back(scene);
}
cin.close();
}
示例8: parseXML
CoronaLoader::CoronaLoader(const FileName& fileName, const AffineSpace3fa& space)
{
path = fileName.path();
Ref<XML> xml = parseXML(fileName,"/.-",false);
if (xml->name == "scene")
{
Ref<SceneGraph::GroupNode> group = new SceneGraph::GroupNode;
for (size_t i=0; i<xml->children.size(); i++) {
group->add(loadNode(xml->children[i]));
}
root = group.cast<SceneGraph::Node>();
}
else
THROW_RUNTIME_ERROR(xml->loc.str()+": invalid scene tag");
if (space == AffineSpace3fa(one))
return;
root = new SceneGraph::TransformNode(space,root);
}
示例9: IsisMain
void IsisMain() {
//Get user parameters
UserInterface &ui = Application::GetUserInterface();
FileName inFile = ui.GetFileName("FROM");
int numberOfLines = ui.GetInteger("NL");
int lineOverlap = ui.GetInteger("OVERLAP");
//Throws exception if user is dumb
if(lineOverlap >= numberOfLines) {
throw IException(IException::User, "The Line Overlap (OVERLAP) must be less than the Number of Lines (LN).", _FILEINFO_);
}
//Opens the cube
Cube cube;
cube.open(inFile.expanded());
//Loops through, cropping as desired
int cropNum = 1;
int startLine = 1;
bool hasReachedEndOfCube = false;
while(startLine <= cube.lineCount() && not hasReachedEndOfCube) {
//! Sets up the proper paramaters for running the crop program
QString parameters = "FROM=" + inFile.expanded() +
" TO=" + inFile.path() + "/" + inFile.baseName() + ".segment" + toString(cropNum) + ".cub"
+ " LINE=" + toString(startLine) + " NLINES=";
if(startLine + numberOfLines > cube.lineCount()) {
parameters += toString(cube.lineCount() - (startLine - 1));
hasReachedEndOfCube = true;
}
else {
parameters += toString(numberOfLines);
}
ProgramLauncher::RunIsisProgram("crop", parameters);
//The starting line for next crop
startLine = 1 + cropNum * (numberOfLines - lineOverlap);
cropNum++;
}
}
示例10: createTempFile
FileName FileName::createTempFile(FileName templateFileName) {
QString preppedFileName = QString("%1/%2XXXXXX.%3").arg(templateFileName.path())
.arg(templateFileName.baseName()).arg(templateFileName.extension());
QTemporaryFile tempFile(preppedFileName);
tempFile.setAutoRemove(false);
if (!tempFile.open()) {
throw IException(IException::Io,
QObject::tr("Could not create a unique temporary file name based on [%1]")
.arg(templateFileName.original()),
_FILEINFO_);
}
// We want to set the 'original' path as correctly as possible. So let's use the input original
// path with the output temp file's file name in our result.
FileName result;
QString newTempFileNameStr = templateFileName.originalPath() + "/" +
QFileInfo(tempFile.fileName()).fileName();
result = FileName(newTempFileNameStr);
return result;
}
示例11: TutorialApplication
SceneLoadingTutorialApplication::SceneLoadingTutorialApplication (const std::string& tutorialName, int features)
: TutorialApplication(tutorialName, features),
scene(new SceneGraph::GroupNode),
convert_tris_to_quads(false),
convert_tris_to_quads_prop(inf),
convert_bezier_to_lines(false),
convert_hair_to_curves(false),
convert_bezier_to_bspline(false),
convert_bspline_to_bezier(false),
remove_mblur(false),
remove_non_mblur(false),
sceneFilename(""),
instancing_mode(SceneGraph::INSTANCING_NONE),
print_scene_cameras(false)
{
registerOption("i", [this] (Ref<ParseStream> cin, const FileName& path) {
sceneFilename = path + cin->getFileName();
}, "-i <filename>: parses scene from <filename>");
registerOption("animlist", [this] (Ref<ParseStream> cin, const FileName& path) {
FileName listFilename = path + cin->getFileName();
std::ifstream listFile;
listFile.open(listFilename.c_str());
if (!listFile.is_open()) {
THROW_RUNTIME_ERROR("cannot open " + listFilename.str());
}
else
{
while (!listFile.eof())
{
std::string line;
listFile >> line;
if (line != "")
keyFramesFilenames.push_back(listFilename.path() + line);
}
}
}, "-animlist <filename>: parses a sequence of .obj/.xml files listed in <filename> and adds them to the scene");
示例12: parseCommandLine
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
while (true)
{
std::string tag = cin->getString();
if (tag == "") return;
/* parse command line parameters from a file */
else if (tag == "-c") {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* load OBJ model*/
else if (tag == "-i") {
filename = path + cin->getFileName();
}
/* parse camera parameters */
else if (tag == "-vp") g_camera.from = cin->getVec3fa();
else if (tag == "-vi") g_camera.to = cin->getVec3fa();
else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
else if (tag == "-vu") g_camera.up = cin->getVec3fa();
else if (tag == "-fov") g_camera.fov = cin->getFloat();
/* frame buffer size */
else if (tag == "-size") {
g_width = cin->getInt();
g_height = cin->getInt();
}
/* full screen mode */
else if (tag == "-fullscreen")
g_fullscreen = true;
/* output filename */
else if (tag == "-o") {
outFilename = cin->getFileName();
g_interactive = false;
}
/* number of frames to render in benchmark mode */
else if (tag == "-benchmark") {
g_skipBenchmarkFrames = cin->getInt();
g_numBenchmarkFrames = cin->getInt();
g_interactive = false;
}
/* rtcore configuration */
else if (tag == "-rtcore")
g_rtcore = cin->getString();
/* number of threads to use */
else if (tag == "-threads")
g_numThreads = cin->getInt();
/* ambient light source */
else if (tag == "-ambientlight")
{
const Vec3fa L = cin->getVec3fa();
g_obj_scene.ambientLights.push_back(OBJScene::AmbientLight(L));
}
/* point light source */
else if (tag == "-pointlight")
{
const Vec3fa P = cin->getVec3fa();
const Vec3fa I = cin->getVec3fa();
g_obj_scene.pointLights.push_back(OBJScene::PointLight(P,I));
}
/* directional light source */
else if (tag == "-directionallight" || tag == "-dirlight")
{
const Vec3fa D = cin->getVec3fa();
const Vec3fa E = cin->getVec3fa();
g_obj_scene.directionalLights.push_back(OBJScene::DirectionalLight(D,E));
}
/* distant light source */
else if (tag == "-distantlight")
{
const Vec3fa D = cin->getVec3fa();
const Vec3fa L = cin->getVec3fa();
const float halfAngle = cin->getFloat();
g_obj_scene.distantLights.push_back(OBJScene::DistantLight(D,L,halfAngle));
}
/* skip unknown command line parameter */
else {
std::cerr << "unknown command line parameter: " << tag << " ";
while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
std::cerr << std::endl;
}
}
}
示例13: parseCommandLine
static void parseCommandLine(Ref<ParseStream> cin, const FileName &path) {
for (std::string term = cin->getString() ; term != "" ; term = cin->getString()) {
/*! Command line parameters from a file. */
if (term == "-c") { FileName file = path + cin->getFileName(); parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path()); }
/* load OBJ model*/
else if (term == "-i") {
filename = path + cin->getFileName();
}
/*! Camera field of view. */
else if (term == "-fov") g_camera.fov = cin->getFloat();
/*! Full screen mode. */
else if (term == "-fullscreen") g_fullscreen = true;
/* output filename */
else if (term == "-o") {
g_interactive = false;
outFilename = cin->getFileName();
}
/*! Embree configuration. */
else if (term == "-rtcore") g_rtcore = cin->getString();
/*! Window size. */
else if (term == "-size") { g_width = cin->getInt(); g_height = cin->getInt(); }
/*! Thread count. */
else if (term == "-threads") { g_numThreads = cin->getInt(); }
/*! Camera view direction. */
else if (term == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
/*! Camera look point. */
else if (term == "-vi") g_camera.to = cin->getVec3fa();
/*! Camera position. */
else if (term == "-vp") g_camera.from = cin->getVec3fa();
/*! Camera up vector. */
else if (term == "-vu") g_camera.up = cin->getVec3fa();
else if (term == "-cache")
g_subdiv_mode = ",subdiv_accel=bvh4.subdivpatch1cached";
else if (term == "-lazy")
g_subdiv_mode = ",subdiv_accel=bvh4.grid.lazy";
else if (term == "-pregenerate")
g_subdiv_mode = ",subdiv_accel=bvh4.grid.eager";
/*! Skip unknown command line parameters. */
else std::cerr << "Unknown command line parameter: " << getParameterString(cin, term) << std::endl;
}
}
示例14: if
TutorialApplication::TutorialApplication (const std::string& tutorialName, int features)
: Application(features),
tutorialName(tutorialName),
shader(SHADER_DEFAULT),
width(512),
height(512),
pixels(nullptr),
outputImageFilename(""),
skipBenchmarkFrames(0),
numBenchmarkFrames(0),
numBenchmarkRepetitions(1),
interactive(true),
fullscreen(false),
window_width(512),
window_height(512),
windowID(0),
time0(getSeconds()),
debug_int0(0),
debug_int1(0),
mouseMode(0),
clickX(0), clickY(0),
speed(1.0f),
moveDelta(zero),
command_line_camera(false),
print_frame_rate(false),
avg_render_time(64,1.0),
avg_frame_time(64,1.0),
avg_mrayps(64,1.0),
print_camera(false),
debug0(0),
debug1(0),
debug2(0),
debug3(0),
iflags_coherent(RTC_INTERSECT_COHERENT),
iflags_incoherent(RTC_INTERSECT_INCOHERENT)
{
/* only a single instance of this class is supported */
assert(instance == nullptr);
instance = this;
/* for best performance set FTZ and DAZ flags in MXCSR control and status register */
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
registerOption("c", [this] (Ref<ParseStream> cin, const FileName& path) {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}, "-c <filename>: parses command line option from <filename>");
registerOption("o", [this] (Ref<ParseStream> cin, const FileName& path) {
outputImageFilename = cin->getFileName();
interactive = false;
}, "-o <filename>: output image filename");
/* camera settings */
registerOption("vp", [this] (Ref<ParseStream> cin, const FileName& path) {
camera.from = cin->getVec3fa();
command_line_camera = true;
}, "--vp <float> <float> <float>: camera position");
registerOption("vi", [this] (Ref<ParseStream> cin, const FileName& path) {
camera.to = cin->getVec3fa();
command_line_camera = true;
}, "--vi <float> <float> <float>: camera lookat position");
registerOption("vd", [this] (Ref<ParseStream> cin, const FileName& path) {
camera.to = camera.from + cin->getVec3fa();
command_line_camera = true;
}, "--vd <float> <float> <float>: camera direction vector");
registerOption("vu", [this] (Ref<ParseStream> cin, const FileName& path) {
camera.up = cin->getVec3fa();
command_line_camera = true;
}, "--vu <float> <float> <float>: camera up vector");
registerOption("fov", [this] (Ref<ParseStream> cin, const FileName& path) {
camera.fov = cin->getFloat();
command_line_camera = true;
}, "--fov <float>: vertical field of view");
/* framebuffer settings */
registerOption("size", [this] (Ref<ParseStream> cin, const FileName& path) {
width = cin->getInt();
height = cin->getInt();
}, "--size <width> <height>: sets image size");
registerOption("fullscreen", [this] (Ref<ParseStream> cin, const FileName& path) {
fullscreen = true;
}, "--fullscreen: starts in fullscreen mode");
//.........这里部分代码省略.........
示例15: parseCommandLine
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
while (true)
{
std::string tag = cin->getString();
if (tag == "") return;
/* parse command line parameters from a file */
else if (tag == "-c") {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* load OBJ model*/
else if (tag == "-i") {
filename = path + cin->getFileName();
}
/* parse camera parameters */
else if (tag == "-vp") g_camera.from = cin->getVec3fa();
else if (tag == "-vi") g_camera.to = cin->getVec3fa();
else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
else if (tag == "-vu") g_camera.up = cin->getVec3fa();
else if (tag == "-fov") g_camera.fov = cin->getFloat();
/* frame buffer size */
else if (tag == "-size") {
g_width = cin->getInt();
g_height = cin->getInt();
}
/* full screen mode */
else if (tag == "-fullscreen")
g_fullscreen = true;
/* output filename */
else if (tag == "-o") {
outFilename = cin->getFileName();
g_interactive = false;
}
else if (tag == "-objlist") {
keyframeList = cin->getFileName();
}
/* subdivision mode */
else if (tag == "-cache")
g_subdiv_mode = ",subdiv_accel=bvh4.subdivpatch1cached";
else if (tag == "-lazy")
g_subdiv_mode = ",subdiv_accel=bvh4.grid.lazy";
else if (tag == "-pregenerate")
g_subdiv_mode = ",subdiv_accel=bvh4.grid.eager";
else if (tag == "-loop")
g_loop_mode = true;
else if (tag == "-anim")
g_anim_mode = true;
else if (tag == "-shader") {
std::string mode = cin->getString();
if (mode == "default" ) g_shader = SHADER_DEFAULT;
else if (mode == "eyelight") g_shader = SHADER_EYELIGHT;
else if (mode == "uv" ) g_shader = SHADER_UV;
else if (mode == "Ng" ) g_shader = SHADER_NG;
else if (mode == "geomID" ) g_shader = SHADER_GEOMID;
else if (mode == "primID" ) g_shader = SHADER_GEOMID_PRIMID;
else throw std::runtime_error("invalid shader:" +mode);
}
/* number of frames to render in benchmark mode */
else if (tag == "-benchmark") {
g_skipBenchmarkFrames = cin->getInt();
g_numBenchmarkFrames = cin->getInt();
g_interactive = false;
}
/* rtcore configuration */
else if (tag == "-rtcore")
g_rtcore = cin->getString();
/* number of threads to use */
else if (tag == "-threads")
g_numThreads = cin->getInt();
/* ambient light source */
else if (tag == "-ambientlight")
{
const Vec3fa L = cin->getVec3fa();
g_obj_scene.ambientLights.push_back(OBJScene::AmbientLight(L));
}
/* point light source */
else if (tag == "-pointlight")
{
const Vec3fa P = cin->getVec3fa();
const Vec3fa I = cin->getVec3fa();
g_obj_scene.pointLights.push_back(OBJScene::PointLight(P,I));
//.........这里部分代码省略.........