本文整理汇总了C++中FileName::toChars方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::toChars方法的具体用法?C++ FileName::toChars怎么用?C++ FileName::toChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::toChars方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setFilename
void Library::setFilename(char *dir, char *filename)
{
char *arg = filename;
if (!arg || !*arg)
{ // Generate lib file name from first obj name
char *n = (char *)global.params.objfiles->data[0];
n = FileName::name(n);
FileName *fn = FileName::forceExt(n, global.lib_ext);
arg = fn->toChars();
}
if (!FileName::absolute(arg))
arg = FileName::combine(dir, arg);
FileName *libfilename = FileName::defaultExt(arg, global.lib_ext);
libfile = new File(libfilename);
}
示例2: json_generate
void json_generate(Array *modules)
{ OutBuffer buf;
buf.writestring("[\n");
for (int i = 0; i < modules->dim; i++)
{ Module *m = (Module *)modules->data[i];
if (global.params.verbose)
printf("json gen %s\n", m->toChars());
m->toJsonBuffer(&buf);
buf.writestring(",\n");
}
JsonRemoveComma(&buf);
buf.writestring("]\n");
// Write buf to file
char *arg = global.params.xfilename;
if (!arg || !*arg)
{ // Generate lib file name from first obj name
char *n = (char *)global.params.objfiles->data[0];
n = FileName::name(n);
FileName *fn = FileName::forceExt(n, global.json_ext);
arg = fn->toChars();
}
else if (arg[0] == '-' && arg[1] == 0)
{ // Write to stdout; assume it succeeds
int n = fwrite(buf.data, 1, buf.offset, stdout);
assert(n == buf.offset); // keep gcc happy about return values
return;
}
// if (!FileName::absolute(arg))
// arg = FileName::combine(dir, arg);
FileName *jsonfilename = FileName::defaultExt(arg, global.json_ext);
File *jsonfile = new File(jsonfilename);
assert(jsonfile);
jsonfile->setbuffer(buf.data, buf.offset);
jsonfile->ref = 1;
char *pt = FileName::path(jsonfile->toChars());
if (*pt)
FileName::ensurePathExists(pt);
mem.free(pt);
jsonfile->writev();
}
示例3: Package
Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen)
: Package(ident)
{
FileName *srcfilename;
// printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars());
this->arg = filename;
md = NULL;
errors = 0;
numlines = 0;
members = NULL;
isHtml = 0;
isDocFile = 0;
needmoduleinfo = 0;
#ifdef IN_GCC
strictlyneedmoduleinfo = 0;
#endif
selfimports = 0;
insearch = 0;
searchCacheIdent = NULL;
searchCacheSymbol = NULL;
searchCacheFlags = 0;
semanticstarted = 0;
semanticRun = 0;
decldefs = NULL;
vmoduleinfo = NULL;
#if IN_DMD
massert = NULL;
munittest = NULL;
marray = NULL;
sictor = NULL;
sctor = NULL;
sdtor = NULL;
stest = NULL;
sfilename = NULL;
#endif
root = 0;
importedFrom = NULL;
srcfile = NULL;
objfile = NULL;
docfile = NULL;
hdrfile = NULL;
debuglevel = 0;
debugids = NULL;
debugidsNot = NULL;
versionlevel = 0;
versionids = NULL;
versionidsNot = NULL;
macrotable = NULL;
escapetable = NULL;
safe = FALSE;
#if IN_DMD
doppelganger = 0;
cov = NULL;
covb = NULL;
#endif
srcfilename = FileName::defaultExt(filename, global.mars_ext);
if (!srcfilename->equalsExt(global.mars_ext) &&
!srcfilename->equalsExt(global.hdr_ext) &&
!srcfilename->equalsExt("dd"))
{
if (srcfilename->equalsExt("html") ||
srcfilename->equalsExt("htm") ||
srcfilename->equalsExt("xhtml"))
isHtml = 1;
else
{ error("source file name '%s' must have .%s extension", srcfilename->toChars(), global.mars_ext);
fatal();
}
}
srcfile = new File(srcfilename);
#if IN_LLVM
// LDC
llvmForceLogging = false;
moduleInfoVar = NULL;
moduleInfoType = llvm::StructType::create(llvm::getGlobalContext());
this->doDocComment = doDocComment;
this->doHdrGen = doHdrGen;
this->isRoot = false;
this->arrayfuncs = 0;
#endif
}
示例4: if
Module *Module::load(Loc loc, Array *packages, Identifier *ident)
{ Module *m;
char *filename;
//printf("Module::load(ident = '%s')\n", ident->toChars());
// Build module filename by turning:
// foo.bar.baz
// into:
// foo\bar\baz
filename = ident->toChars();
if (packages && packages->dim)
{
OutBuffer buf;
int i;
for (i = 0; i < packages->dim; i++)
{ Identifier *pid = (Identifier *)packages->data[i];
buf.writestring(pid->toChars());
#if _WIN32
buf.writeByte('\\');
#else
buf.writeByte('/');
#endif
}
buf.writestring(filename);
buf.writeByte(0);
filename = (char *)buf.extractData();
}
m = new Module(filename, ident, 0, 0);
m->loc = loc;
/* Search along global.path for .di file, then .d file.
*/
char *result = NULL;
FileName *fdi = FileName::forceExt(filename, global.hdr_ext);
FileName *fd = FileName::forceExt(filename, global.mars_ext);
char *sdi = fdi->toChars();
char *sd = fd->toChars();
if (FileName::exists(sdi))
result = sdi;
else if (FileName::exists(sd))
result = sd;
else if (FileName::absolute(filename))
;
else if (!global.path)
;
else
{
for (size_t i = 0; i < global.path->dim; i++)
{
char *p = (char *)global.path->data[i];
char *n = FileName::combine(p, sdi);
if (FileName::exists(n))
{ result = n;
break;
}
mem.free(n);
n = FileName::combine(p, sd);
if (FileName::exists(n))
{ result = n;
break;
}
mem.free(n);
}
}
if (result)
m->srcfile = new File(result);
if (global.params.verbose)
{
printf("import ");
if (packages)
{
for (size_t i = 0; i < packages->dim; i++)
{ Identifier *pid = (Identifier *)packages->data[i];
printf("%s.", pid->toChars());
}
}
printf("%s\t(%s)\n", ident->toChars(), m->srcfile->toChars());
}
m->read(loc);
m->parse();
#ifdef IN_GCC
d_gcc_magic_module(m);
#endif
return m;
}
示例5: runLINK
int runLINK()
{
#if _WIN32
if (global.params.is64bit)
{
OutBuffer cmdbuf;
for (size_t i = 0; i < global.params.objfiles->dim; i++)
{
if (i)
cmdbuf.writeByte(' ');
char *p = (*global.params.objfiles)[i];
char *basename = FileName::removeExt(FileName::name(p));
char *ext = FileName::ext(p);
if (ext && !strchr(basename, '.'))
// Write name sans extension (but not if a double extension)
writeFilename(&cmdbuf, p, ext - p - 1);
else
writeFilename(&cmdbuf, p);
mem.free(basename);
}
if (global.params.resfile)
{
cmdbuf.writeByte(' ');
writeFilename(&cmdbuf, global.params.resfile);
}
cmdbuf.writeByte(' ');
if (global.params.exefile)
{ cmdbuf.writestring("/OUT:");
writeFilename(&cmdbuf, global.params.exefile);
}
else
{ /* Generate exe file name from first obj name.
* No need to add it to cmdbuf because the linker will default to it.
*/
char *n = (*global.params.objfiles)[0];
n = FileName::name(n);
FileName *fn = FileName::forceExt(n, "exe");
global.params.exefile = fn->toChars();
}
// Make sure path to exe file exists
{ char *p = FileName::path(global.params.exefile);
FileName::ensurePathExists(p);
mem.free(p);
}
cmdbuf.writeByte(' ');
if (global.params.mapfile)
{ cmdbuf.writestring("/MAP:");
writeFilename(&cmdbuf, global.params.mapfile);
}
else if (global.params.map)
{
FileName *fn = FileName::forceExt(global.params.exefile, "map");
char *path = FileName::path(global.params.exefile);
char *p;
if (path[0] == '\0')
p = FileName::combine(global.params.objdir, fn->toChars());
else
p = fn->toChars();
cmdbuf.writestring("/MAP:");
writeFilename(&cmdbuf, p);
}
for (size_t i = 0; i < global.params.libfiles->dim; i++)
{
cmdbuf.writeByte(' ');
cmdbuf.writestring("/DEFAULTLIB:");
writeFilename(&cmdbuf, (*global.params.libfiles)[i]);
}
if (global.params.deffile)
{
cmdbuf.writeByte(' ');
cmdbuf.writestring("/DEF:");
writeFilename(&cmdbuf, global.params.deffile);
}
if (global.params.symdebug)
{
cmdbuf.writeByte(' ');
cmdbuf.writestring("/DEBUG");
}
if (global.params.dll)
{
cmdbuf.writeByte(' ');
cmdbuf.writestring("/DLL");
}
cmdbuf.writestring(" /MERGE:.minfobg=.minfodt /MERGE:.minfoen=.minfodt");
cmdbuf.writestring(" /MERGE:._deh_bg=._deh_eh /MERGE:._deh_en=._deh_eh");
for (size_t i = 0; i < global.params.linkswitches->dim; i++)
{
//.........这里部分代码省略.........
示例6: runLINK
int runLINK()
{
#if _WIN32
char *p;
int i;
int status;
OutBuffer cmdbuf;
global.params.libfiles->push((void *) "user32");
global.params.libfiles->push((void *) "kernel32");
for (i = 0; i < global.params.objfiles->dim; i++)
{
if (i)
cmdbuf.writeByte('+');
p = (char *)global.params.objfiles->data[i];
char *ext = FileName::ext(p);
if (ext)
cmdbuf.write(p, ext - p - 1);
else
cmdbuf.writestring(p);
}
cmdbuf.writeByte(',');
if (global.params.exefile)
cmdbuf.writestring(global.params.exefile);
else
{ // Generate exe file name from first obj name
char *n = (char *)global.params.objfiles->data[0];
char *ex;
n = FileName::name(n);
FileName *fn = FileName::forceExt(n, "exe");
global.params.exefile = fn->toChars();
}
cmdbuf.writeByte(',');
if (global.params.run)
cmdbuf.writestring("nul");
// if (mapfile)
// cmdbuf.writestring(output);
cmdbuf.writeByte(',');
for (i = 0; i < global.params.libfiles->dim; i++)
{
if (i)
cmdbuf.writeByte('+');
cmdbuf.writestring((char *) global.params.libfiles->data[i]);
}
if (global.params.deffile)
{
cmdbuf.writeByte(',');
cmdbuf.writestring(global.params.deffile);
}
/* Eliminate unnecessary trailing commas */
while (1)
{ i = cmdbuf.offset;
if (!i || cmdbuf.data[i - 1] != ',')
break;
cmdbuf.offset--;
}
if (global.params.resfile)
{
cmdbuf.writestring("/RC:");
cmdbuf.writestring(global.params.resfile);
}
#if 0
if (mapfile)
cmdbuf.writestring("/m");
if (debuginfo)
cmdbuf.writestring("/li");
if (codeview)
{
cmdbuf.writestring("/co");
if (codeview3)
cmdbuf.writestring(":3");
}
#else
if (global.params.symdebug)
cmdbuf.writestring("/co");
#endif
cmdbuf.writestring("/noi");
for (i = 0; i < global.params.linkswitches->dim; i++)
{
cmdbuf.writestring((char *) global.params.linkswitches->data[i]);
}
cmdbuf.writeByte(';');
p = cmdbuf.toChars();
char *linkcmd = getenv("LINKCMD");
if (!linkcmd)
linkcmd = "link";
status = executecmd(linkcmd, p, 1);
return status;
#elif linux
//.........这里部分代码省略.........
示例7: if
Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen)
: Package(ident)
{
FileName *srcfilename;
FileName *objfilename;
FileName *symfilename;
// printf("Module::Module(filename = '%s', ident = '%s')\n", filename, ident->toChars());
this->arg = filename;
md = NULL;
errors = 0;
numlines = 0;
members = NULL;
isHtml = 0;
isDocFile = 0;
needmoduleinfo = 0;
#ifdef IN_GCC
strictlyneedmoduleinfo = 0;
#endif
selfimports = 0;
insearch = 0;
searchCacheIdent = NULL;
searchCacheSymbol = NULL;
searchCacheFlags = 0;
semanticstarted = 0;
semanticRun = 0;
decldefs = NULL;
vmoduleinfo = NULL;
massert = NULL;
munittest = NULL;
marray = NULL;
sictor = NULL;
sctor = NULL;
sdtor = NULL;
ssharedctor = NULL;
sshareddtor = NULL;
stest = NULL;
sfilename = NULL;
root = 0;
importedFrom = NULL;
srcfile = NULL;
docfile = NULL;
debuglevel = 0;
debugids = NULL;
debugidsNot = NULL;
versionlevel = 0;
versionids = NULL;
versionidsNot = NULL;
macrotable = NULL;
escapetable = NULL;
safe = FALSE;
doppelganger = 0;
cov = NULL;
covb = NULL;
nameoffset = 0;
namelen = 0;
srcfilename = FileName::defaultExt(filename, global.mars_ext);
if (!srcfilename->equalsExt(global.mars_ext) &&
!srcfilename->equalsExt(global.hdr_ext) &&
!srcfilename->equalsExt("dd"))
{
if (srcfilename->equalsExt("html") ||
srcfilename->equalsExt("htm") ||
srcfilename->equalsExt("xhtml"))
{ if (!global.params.useDeprecated)
error("html source files is deprecated %s", srcfilename->toChars());
isHtml = 1;
}
else
{ error("source file name '%s' must have .%s extension", srcfilename->toChars(), global.mars_ext);
fatal();
}
}
char *argobj;
if (global.params.objname)
argobj = global.params.objname;
#if 0
else if (global.params.preservePaths)
argobj = filename;
else
argobj = FileName::name(filename);
if (!FileName::absolute(argobj))
{
argobj = FileName::combine(global.params.objdir, argobj);
}
#else // Bugzilla 3547
else
{
if (global.params.preservePaths)
argobj = filename;
else
argobj = FileName::name(filename);
if (!FileName::absolute(argobj))
{
argobj = FileName::combine(global.params.objdir, argobj);
//.........这里部分代码省略.........