本文整理汇总了C++中Pathname类的典型用法代码示例。如果您正苦于以下问题:C++ Pathname类的具体用法?C++ Pathname怎么用?C++ Pathname使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pathname类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveDirectoryFull
static bool RemoveDirectoryFull(const Pathname &p, int part, char *buff, int bufsize)
{
if (p.GetPart(part+1,buff,bufsize,-1))
if (RemoveDirectoryFull(p,part+1,buff,bufsize) == false) return false;
p.GetPart(part,buff,bufsize, -1);
return RemoveDirectory(buff) != FALSE;
}
示例2: current_thread
void Autoload::load()
{
Thread * const thread = current_thread();
void * last_special_binding = thread->last_special_binding();
thread->bind_special(S_current_readtable, thread->symbol_value(S_standard_readtable));
thread->bind_special(S_current_package, make_value(PACKAGE_SYS));
thread->bind_special(S_read_base, FIXNUM_TEN);
if (thread->symbol_value(S_autoload_verbose) != NIL)
{
String * prefix = new String(xcl_home());
prefix->append_char('/');
if (_filename == NULL)
prefix->append("lisp/");
Pathname * defaults = check_pathname(parse_namestring(prefix));
Value device = defaults->device();
Value directory = defaults->directory();
Value name;
if (_filename)
name = make_value(new_simple_string(_filename));
else
name = make_value(the_symbol(operator_name())->name()->downcase());
Value type = make_simple_string("xcl");
Pathname * pathname = new Pathname(NIL, device, directory, name, type, NIL);
if (CL_probe_file(make_value(pathname)) == NIL)
{
type = make_simple_string("lisp");
pathname = new Pathname(NIL, device, directory, name, type, NIL);
}
AbstractString * namestring = pathname->namestring();
AnsiStream * out = check_ansi_stream(thread->symbol_value(S_standard_output));
String * message = new String("; Autoloading ");
message->append(::prin1_to_string(operator_name())->as_c_string());
message->append(" from ");
message->append(namestring);
message->append(" ...\n");
out->fresh_line();
out->write_string(message);
CL_load(make_value(namestring));
message = new String("; Autoloaded ");
message->append(namestring);
message->append("\n");
out->fresh_line();
out->write_string(message);
}
else if (_filename)
{
SYS_load_system_file(make_value(_filename));
}
else
{
String * namestring = new String("lisp/");
namestring->append(the_symbol(operator_name())->name()->downcase());
SYS_load_system_file(make_value(namestring));
}
thread->set_last_special_binding(last_special_binding);
}
示例3: action
SpriteAction*
SpriteData::parse_action(const Pathname& dir, FileReader& reader)
{
std::auto_ptr<SpriteAction> action (new SpriteAction);
action->speed = 1.0;
action->scale = 1.0f;
action->offset = Vector2f(0, 0);
reader.get("name", action->name);
reader.get("speed", action->speed);
reader.get("scale", action->scale);
reader.get("offset", action->offset);
FileReader grid_reader;
std::vector<std::string> image_files;
if(reader.get("images", image_files))
{
//parse_images(action.get(), dir, images);
for(std::vector<std::string>::iterator file = image_files.begin(); file != image_files.end(); ++file)
{
Pathname path = dir;
path.append_path(*file);
action->surfaces.push_back(SurfaceManager::current()->get(path));
}
}
else if(reader.get("image-grid", grid_reader))
{
std::string filename;
int x_size = -1;
int y_size = -1;
grid_reader.get("file", filename);
grid_reader.get("x-size", x_size);
grid_reader.get("y-size", y_size);
if(filename.empty() || x_size <= 0 || y_size <= 0)
throw std::runtime_error("Invalid or too few data in image-grid");
Pathname path = dir;
path.append_path(filename);
SurfaceManager::current()->load_grid(path, action->surfaces, x_size, y_size);
}
if(action->name == "")
throw std::runtime_error("No Name defined for action");
if(action->surfaces.size() == 0)
{
std::ostringstream msg;
msg << "Action '" << action->name << "' contains no images";
throw std::runtime_error(msg.str());
}
return action.release();
}
示例4: load_plf_raw
PingusLevel
PLFResMgr::load_plf_from_filename(const Pathname& pathname)
{
// FIXME: Ugly resname guessing is ugly
std::string res_name = System::basename(pathname.get_sys_path());
// This should give us the tutorial/, wip/, etc. part of the res_name
std::string dirname = System::basename(System::dirname(pathname.get_sys_path()));
return load_plf_raw(dirname + "/" + res_name.substr(0, res_name.length()-7),
pathname);
}
示例5: FullToRelative
bool Pathname::FullToRelative(const Pathname &relativeto)
{
if (relativeto.IsNull() || IsNull()) return false;
bool h1= HasDrive();
bool h2= relativeto.HasDrive();
if (h1 != h2) return false; //rozdilny zpusob adresace - nelze vytvorit relatvni cestu
if (h1== true && h2== true && toupper(GetDrive()) != toupper(relativeto.GetDrive()))
return false; //ruzne disky, nelze vytvorit relativni cestu
if (strncmp(_path,"\\\\",2) == 0) //sitova cesta
{
int slsh = 0; //citac lomitek
const char *a = _path;
const char *b = relativeto._path;
while (toupper(*a) == toupper(*b) && *a && slsh<3) //zacatek sitove cesty musi byt stejny
{
if (*a =='\\') slsh++;
a++;b++;
}
if (slsh != 3) return false; //pokud neni stejny, nelze vytvorit relativni cestu
}
int sublevel = 0;
const char *ps1= _path;
const char *ps2= relativeto._path;
if (h1)
{ps1 += 2;ps2 += 2;}
const char *sls = ps2;
while (toupper(*ps1) == toupper(*ps2) && *ps1)
{
if (*ps2=='\\') sls = ps2+1;
ps1++;ps2++;
}
ps1 -= ps2-sls;
if (sls)
{
while (sls = strchr(sls,'\\'))
{
sls++;
sublevel++;
}
}
char *buff = (char *)alloca((sublevel*3+strlen(ps1)+1)*sizeof(*buff));
char *pos = buff;
for (int i = 0;i<sublevel;i++)
{strcpy(pos,"..\\");pos += 3;}
strcpy(pos,ps1);
SetDrive(0);
SetDirectory(buff);
return true;
}
示例6: visit_Pathname
bool visit_Pathname(Pathname & p)
{
//std::cout << "### apply(" << this->_base_dir << ") to " << p << " ... reset=" << this->_reset << std::endl;
//std::cout << "p before: b<" << p.base_dir() << "> r<" << p.rel_path() << "> a<" << p.abs_path() << "> i<" << p.is_abs() << ">" << &p << std::endl;
if(this->_reset)
{
p.reset_base_dir(this->_base_dir);
}
else
{
p.set_base_dir(this->_base_dir);
}
//std::cout << "p after: b<" << p.base_dir() << "> r<" << p.rel_path() << "> a<" << p.abs_path() << "> i<" << p.is_abs() << ">" << &p << std::endl;
return true;
}
示例7:
PingusDemo::PingusDemo(const Pathname& pathname) :
m_levelname(),
m_checksum(),
m_events()
{
std::vector<FileReader> lines = FileReader::parse_many(pathname);
if (lines.empty())
{
raise_exception(std::runtime_error, "'" << pathname.str() << "', demo file is empty");
}
else
{
if (lines.front().get_name() == "level")
{
const FileReader& reader = lines.front();
if (!reader.read_string("name", m_levelname))
{
raise_exception(std::runtime_error, "(level (name ...)) entry missing in demo file '" << pathname.str() << "'");
}
reader.read_string("checksum", m_checksum);
}
for(std::vector<FileReader>::iterator i = lines.begin()+1; i != lines.end(); ++i)
{
if (i->get_name() != "checksum") // workaround for old incorrectly recorded demo files
{
m_events.push_back(ServerEvent(*i));
}
}
}
}
示例8: writer
void
Options::save(const Pathname& filename) const
{
std::ostringstream out;
SExprFileWriter writer(out);
writer.begin_section("pingus-config");
if (framebuffer_type.is_set())
writer.write_enum("renderer", framebuffer_type.get(), framebuffer_type_to_string);
if (master_volume.is_set())
writer.write_int("master-volume", master_volume.get());
if (sound_volume.is_set())
writer.write_int("sound-volume", sound_volume.get());
if (music_volume.is_set())
writer.write_int("music-volume", music_volume.get());
if (geometry.is_set())
writer.write_size("geometry", geometry.get());
if (fullscreen_resolution.is_set())
writer.write_size("fullscreen-resolution", fullscreen_resolution.get());
if (fullscreen.is_set())
writer.write_bool("fullscreen", fullscreen.get());
if (resizable.is_set())
writer.write_bool("resizable", resizable.get());
if (mouse_grab.is_set())
writer.write_bool("mouse-grab", mouse_grab.get());
if (print_fps.is_set())
writer.write_bool("print-fps", print_fps.get());
if (controller.is_set())
writer.write_string("controller", controller.get());
if (language.is_set())
writer.write_string("language", language.get());
if (software_cursor.is_set())
writer.write_bool("software-cursor", software_cursor.get());
if (auto_scrolling.is_set())
writer.write_bool("auto-scrolling", auto_scrolling.get());
if (drag_drop_scrolling.is_set())
writer.write_bool("drag-drop-scrolling", drag_drop_scrolling.get());
writer.end_section(); // pingus-config
out << std::endl;
System::write_file(filename.get_sys_path(), out.str());
}
示例9: SurfaceImpl
Surface::Surface(const Pathname& pathname)
{
SDL_Surface* surface = IMG_Load(pathname.get_sys_path().c_str());
if (surface)
{
impl = boost::shared_ptr<SurfaceImpl>(new SurfaceImpl(surface, true));
}
}
示例10:
// Save the current level
void
EditorScreen::save(const Pathname& file)
{
std::string filename = file.get_sys_path();
if (System::get_file_extension(filename) == "prefab")
{
level_pathname = file;
log_info("Save to: %1%", file.str());
plf->save_prefab(filename);
}
else
{
level_pathname = file;
log_info("Save to: %1%", file.str());
plf->save_level(filename);
}
}
示例11: completion
Levelset::Levelset(const Pathname& pathname)
: completion(0)
{
FileReader reader = FileReader::parse(pathname);
if (reader.get_name() != "pingus-levelset")
{
PingusError::raise("Error: " + pathname.str() + ": not a 'pingus-levelset' file");
}
else
{
reader.read_string("title", title);
reader.read_string("description", description);
std::string image;
if (reader.read_string("image", image))
this->image = Resource::load_sprite(image);
FileReader level_reader = reader.read_section("levels");
std::vector<FileReader> sections = level_reader.get_sections();
for(std::vector<FileReader>::iterator i = sections.begin(); i != sections.end(); ++i)
{
if (i->get_name() == "level")
{
Level* level = new Level();
if (i->read_string("filename", level->resname))
{
level->plf = PLFResMgr::load_plf(level->resname);
level->accessible = false;
level->finished = false;
levels.push_back(level);
}
else
{
std::cout << "Levelset: " << pathname.str() << " is missing filename tag" << std::endl;
delete level;
}
}
}
}
refresh();
}
示例12: assert
void
ResourceManager::add_resources_from_directory(const Pathname& path)
{
assert(path.get_type() == Pathname::DATA_PATH);
std::vector<std::string> files = System::opendir_recursive(path.get_sys_path());
for(auto it = files.begin(); it != files.end(); ++it)
{
if (StringUtil::has_suffix(*it, ".sprite") ||
StringUtil::has_suffix(*it, ".png") ||
StringUtil::has_suffix(*it, ".jpg"))
{
// FIXME: ugly hack to remove "data/images/" prefix, need better
// way to cut stuff away
m_resources.push_back(System::cut_file_extension(it->substr(12)));
}
}
std::sort(m_resources.begin(), m_resources.end());
}
示例13: plf
PingusLevel
PLFResMgr::load_plf_raw(const std::string& res_name,
const Pathname& pathname)
{
pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: '" << res_name << "' -> '" << pathname.str() << "'" << std::endl;
PLFMap::iterator i = plf_map.find(res_name);
if (i == plf_map.end())
{ // Entry not cached, so load it and add it to cache
pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from DISK: '" << res_name << "' -> '"
<< pathname.str() << "'" << std::endl;
PingusLevel plf(res_name, pathname);
PLFEntry entry;
entry.plf = plf;
entry.mtime = pathname.mtime();
plf_map[res_name] = entry;
// FIXME: leaking pointers to the outsite work is not such a good
// idea, could lead to trouble sooner or later
return PingusLevel (entry.plf);
}
else
{
uint64_t current_mtime = pathname.mtime();
if (current_mtime != i->second.mtime)
{
pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: level changed on DISK, reloading: '" << res_name
<< "' -> '" << pathname.str() << "'" << std::endl;
// Reload the file since it has changed on disk
PingusLevel plf(res_name, pathname);
PLFEntry entry;
entry.plf = plf;
entry.mtime = pathname.mtime();
plf_map[res_name] = entry;
// FIXME: leaking pointers to the outsite work is not such a good
// idea, could lead to trouble sooner or later
return PingusLevel (entry.plf);
}
else
{ // File in cache is up to date, everything is all ready, return it
pout(PINGUS_DEBUG_LOADING) << "PLFResMgr: Loading level from CACHE: '" << res_name << "' -> '"
<< pathname.str() << "'" << std::endl;
return i->second.plf;
}
}
}
示例14: RelativeToFull
bool Pathname::RelativeToFull(const Pathname &ref)
{
if (ref.IsNull() || IsNull()) return false;
const char *beg;
if (HasDrive())
if (toupper(GetDrive()) != toupper(ref.GetDrive())) return false;
else beg = _path+2;
else beg = _path;
const char *end = strchr(ref._path,0);
if (beg[0] =='\\')
{
int np;
if (ref.HasDrive()) end = ref._path+2;
else if (np = ref.IsNetworkPath()) end = ref._path+np;
else end = ref._path;
}
else while (strncmp(beg,"..\\",3) == 0 || strncmp(beg,".\\",2) == 0)
{
if (beg[1] =='.')
{
if (end>ref._path)
{
end--;
while (end>ref._path && end[-1]!='\\') end--;
}
beg += 3;
}
else
beg += 2;
}
int partln = end-ref._path;
char *buff = (char *)alloca((partln+strlen(beg)+1)*sizeof(*buff));
memcpy(buff,ref._path,partln);
strcpy(buff+partln,beg);
SetDrive(0);
SetDirectory(buff);
return true;
}
示例15: plf
std::unique_ptr<EditorLevel>
EditorLevel::from_level_file(const Pathname& pathname)
{
log_info("%1%", pathname.str());
// Load the level from the file - we don't care what it's res_name is.
PingusLevel plf(pathname);
std::unique_ptr<EditorLevel> level(new EditorLevel);
// Assign all of the level information to our LevelImpl
level->impl->levelname = plf.get_levelname();
level->impl->description = plf.get_description();
level->impl->ambient_light = plf.get_ambient_light();
level->impl->size = plf.get_size();
level->impl->number_of_pingus = plf.get_number_of_pingus();
level->impl->number_to_save = plf.get_number_to_save();
level->impl->actions = plf.get_actions();
level->impl->time = plf.get_time();
level->impl->author = plf.get_author();
level->impl->music = plf.get_music();
// remove obsolete "none" tag
if (level->impl->music == "none")
{
level->impl->music = "";
}
// Get the objects
auto objs = plf.get_objects();
for (auto i = objs.begin(); i != objs.end(); i++)
{
LevelObjPtr obj = LevelObjFactory::create(*i);
if (obj)
{
level->add_object(obj);
}
}
level->sort();
return level;
}