示例#1
0
void parse_cmd_line(const deque<wstring>& params, list<wstring>& source_dirs, list<wstring>& include_dirs) {
  source_dirs.assign(1, wstring());
  for (auto param = params.cbegin(); param != params.cend(); ++param) {
    if (substr_match(*param, 0, L"-I")) {
      wstring inc_dir = param->substr(2);
      CHECK_CMD(!inc_dir.empty());
      fix_slashes(inc_dir);
      include_dirs.push_back(inc_dir);
    }
    else {
      wstring src_dir = *param;
      fix_slashes(src_dir);
      source_dirs.push_back(src_dir);
    }
  }
}
示例#2
0
文件: osdir.c 项目: wolfpython/nelvis
/* combine a directory name and a filename, yielding a pathname. */
char *
dirpath (char *dir, /* directory name */
         char *file)/* filename */
{
  static char  path[CCHMAXPATH];

  /* Convert slashes to backslashes. */
  fix_slashes (dir);
  fix_slashes (file);

  if (strcmp (dir, ".") == 0
      || dir[0] == '\0'
      || (elvalpha (file[0]) && file[1] == ':')
      || (!(elvalpha (dir[0]) && dir[1] == ':') && file[0] == OSPATHSEP))
    {
      /* no dir, or file has drive letter, or file is absolute within
       * drive but dir doesn't specify drive.
       */
      strcpy (path, file);
    }
  else if (elvalpha (dir[0]) && dir[1] == ':' && file[0] == OSPATHSEP)
    {
      /* dir has drive letter, and file is absolute within drive */
      sprintf (path, "%.2s%s", dir, file);
    }
  else if (!dir[0] || dir[strlen(dir) - 1] != OSPATHSEP)
    {
      /* dir ends without \, and file is relative to dir */
      sprintf (path, "%s\\%s", dir, file);
    }
  else
    {
      /* dir ends with \, and file is relative to dir */
      sprintf (path, "%s%s", dir, file);
    }
  return path;
}
示例#3
0
list<wstring> get_include_file_list(const wstring& file_path, const list<wstring>& include_dirs) {
  list<wstring> file_list;
  wstring text = load_file(file_path);
  wstring inc_file;
  size_t pos = 0;
  while (true) {
    if (is_include_directive(text, pos, inc_file)) {
      fix_slashes(inc_file);
      wstring inc_path = add_trailing_slash(extract_file_path(file_path)) + inc_file;
      bool found = file_exists(inc_path);
      for (list<wstring>::const_iterator inc_dir = include_dirs.begin(); !found && inc_dir != include_dirs.end(); inc_dir++) {
        inc_path = add_trailing_slash(*inc_dir) + inc_file;
        found = file_exists(inc_path);
      }
      if (found) file_list.push_back(inc_path);
    }
    pos = text.find(L'\n', pos);
    if (pos == wstring::npos) break;
    else pos++;
  }
  return file_list;
}
示例#4
0
void _fixpath(const char *in, char *out)
{
 char * combined;
 combined=__libc_combine_path((char *)in);
 fix_slashes(combined,out);
}
示例#5
0
// Constructor
directories::directories(char *argv0)
{
  char *dirname = (char *)g_path_get_dirname (argv0);
  rundir = dirname;
  free(dirname);
  char *basename = (char *)g_path_get_basename (argv0);
  exename = basename;
  free(basename);

  // Instead of re-computing the directory every time
  // get_package_data() is called, we compute it once and store it,
  // making repeated calls more efficient by simply returning the
  // answer we have pre-computed.
#ifdef WIN32
  // A clever way to take a path like C:\Program
  // Files\Bibledit-Gtk\editor\bin\ and chop the
  // last component to get back to <something>\Bibledit-Gtk\editor...
  package_data = gw_path_get_dirname(rundir);
  // ... Then add two more dirs back on, resulting in
  // <something>Bibledit-Gtk\editor\share\bibledit
  package_data = gw_build_filename(package_data, "share", "bibledit");
#else
  // For Linux, this is hard-coded to match the variable set in config.h
  package_data = PACKAGE_DATA_DIR;
#endif
  package_data = fix_slashes(package_data);

  // The root directory of all data.
  root = tiny_directories_get_root();
  root = fix_slashes(root);

  // Directory containing all the projects
  projects = tiny_directories_get_projects();
  projects = fix_slashes(projects);

  // Directory with the notes
  notes = gw_build_filename(root, "notes");
  notes = fix_slashes(notes);

  // Directory with the stylesheets
  stylesheets = gw_build_filename(root, "stylesheets");
  stylesheets = fix_slashes(stylesheets);

  // Directory with the configuration
  configuration = gw_build_filename(root, "configuration");
  configuration = fix_slashes(configuration);

  // Directory with the pictures
  pictures = gw_build_filename(root, "pictures");
  pictures = fix_slashes(pictures);

  // Directory with the resources.
  resources = gw_build_filename(root, "resources");
  resources = fix_slashes(resources);

  // Directory with the scripts.
  scripts = gw_build_filename(root, "scripts");
  scripts = fix_slashes(scripts);

  // Temporary directory bibledit uses.
  temp = gw_build_filename(g_get_tmp_dir(), "bibledit");
  temp = fix_slashes(temp);

  // Directory with the templates
  templates = gw_build_filename(get_temp(), "templates");
  templates = fix_slashes(templates);

  // Directory with the User's custom raw templates
  templates_user = gw_build_filename(root, "templates");
  templates_user = fix_slashes(templates_user);

  // Directory, if exists, to restore from
  restore = root + ".restored";
  restore = fix_slashes(restore);
}