Ejemplo n.º 1
0
void guiLoadFont(void)
{
#ifdef CONFIG_FREETYPE
    load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor);
#else
    if (vo_font) {
        int i;

        free(vo_font->name);
        free(vo_font->fpath);

        for (i = 0; i < 16; i++) {
            if (vo_font->pic_a[i]) {
                free(vo_font->pic_a[i]->bmp);
                free(vo_font->pic_a[i]->pal);
            }
        }

        for (i = 0; i < 16; i++) {
            if (vo_font->pic_b[i]) {
                free(vo_font->pic_b[i]->bmp);
                free(vo_font->pic_b[i]->pal);
            }
        }

        free(vo_font);
        vo_font = NULL;
    }

    if (font_name) {
        vo_font = read_font_desc(font_name, font_factor, 0);

        if (!vo_font)
            gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name);
    } else {
        font_name = gstrdup(get_path("font/font.desc"));
        vo_font   = read_font_desc(font_name, font_factor, 0);

        if (!vo_font) {
            gfree((void **)&font_name);
            font_name = gstrdup(MPLAYER_DATADIR "/font/font.desc");
            vo_font   = read_font_desc(font_name, font_factor, 0);
        }
    }
#endif
}
Ejemplo n.º 2
0
		virtual void read(boost::shared_ptr<nscapi::settings_proxy> proxy, bool oneliner, bool is_sample) {
			parent::read(proxy, oneliner, is_sample);

			nscapi::settings_helper::settings_registry settings(proxy);

			nscapi::settings_helper::path_extension root_path = settings.path(get_path());
			if (is_sample)
				root_path.set_sample();

			if (is_default()) {

				root_path.add_key()

					("path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "perf path", _1), "system.${hostname}.${check_alias}.${perf_alias}"),
						"PATH FOR METRICS", "Path mapping for metrics")

					("status path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "status path", _1), "system.${hostname}.${check_alias}.status"),
						"PATH FOR STATUS", "Path mapping for status")

					("send perfdata", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send perfdata", _1), true),
						"SEND PERF DATA", "Send performance data to this server")

					("send status", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send status", _1), true),
						"SEND STATUS", "Send status data to this server")

					;
			} else {
				root_path.add_key()

					("path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "perf path", _1)),
						"PATH FOR METRICS", "Path mapping for metrics")

					("status path", sh::string_fun_key(boost::bind(&parent::set_property_string, this, "status path", _1)),
						"PATH FOR STATUS", "Path mapping for status")

					("send perfdata", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send perfdata", _1)),
						"SEND PERF DATA", "Send performance data to this server")

					("send status", sh::bool_fun_key(boost::bind(&parent::set_property_bool, this, "send status", _1)),
						"SEND STATUS", "Send status data to this server")

					;
			}
			settings.register_all();
			settings.notify();
		}
Ejemplo n.º 3
0
Archivo: mac.c Proyecto: ALPHAMARIOX/pn
int mstat(const char* file, struct stat* st)
{
	CInfoPBRec		pb;
	unsigned char	path[256];
	int				result = 0;

	memset(&pb, 0, sizeof(CInfoPBRec));

	if (strcmp(file, ".") == 0)
	{
		memset(st, 0, sizeof(struct stat));
		st->st_mode = S_IFDIR;
		st->st_ino = -1;
	}
	else
	{
		result = get_path(file, path);
		
		if (result == 0)
		{
			pb.hFileInfo.ioNamePtr = path;
			
			if (PBGetCatInfoSync(&pb) != noErr)
				result = -1;
			else
			{
				memset(st, 0, sizeof(struct stat));
	
				if (pb.hFileInfo.ioFlAttrib & ioDirMask)
					st->st_mode = S_IFDIR;
				else
					st->st_mode = S_IFREG;

				st->st_ino = pb.hFileInfo.ioFlStBlk;
				st->st_dev = pb.hFileInfo.ioVRefNum;
				st->st_nlink = 1;
				st->st_size = pb.hFileInfo.ioFlLgLen;
				st->st_atime = pb.hFileInfo.ioFlMdDat;
				st->st_mtime = pb.hFileInfo.ioFlMdDat;
				st->st_ctime = pb.hFileInfo.ioFlCrDat;
			}
		}
	}

	return result;
}
Ejemplo n.º 4
0
 // get the path from behind
 void get_path(vector<vector<string> > &m_ret, vector<string> &path, string start, string end, 
 unordered_map<string,vector<string> > &m_prev) {
     path.push_back(end);
     if (start == end) {
         // add one valid path
         vector<string> toAdd = path;
 		reverse(toAdd.begin(), toAdd.end());
 		m_ret.push_back(toAdd); 
     }
     else {
         for (const auto &word : m_prev[end]) {
 			get_path(m_ret, path, start, word, m_prev);
 		}
     } 
     path.pop_back();
     return;
 }
Ejemplo n.º 5
0
/* FIXME: The allocation of MAX_PATH on the stack in a recursive
 *        function WILL cause problems, eventually!
 */
static bool check_create_basedir(const char *file)
{
  static struct stat s;
  char path[MAX_PATH];
  ssize_t ret;

  ret = get_path(file, path, MAX_PATH);
  if(ret < 0)
  {
    error("Failed to create directories (path too long)", 1, 8, 0);
    return false;
  }

  // This file has no base directory
  if(ret == 0)
    return true;

  if(stat(path, &s) < 0)
  {
    // Every other kind of error is fatal
    if(errno != ENOENT)
    {
      error("Unknown stat() error occurred", 1, 8, 0);
      return false;
    }

    // Recursion; create any parent directory
    if(!check_create_basedir(path))
      return false;

    // At the tail of the recursion we create the directory
    mkdir(path, 0777);
    return true;
  }

  if(!S_ISDIR(s.st_mode))
  {
    snprintf(widget_buf, WIDGET_BUF_LEN,
     "File \"%s\" prevents creation of directory by same name", path);
    widget_buf[WIDGET_BUF_LEN - 1] = 0;
    error(widget_buf, 1, 8, 0);
    return false;
  }

  return true;
}
Ejemplo n.º 6
0
bool bootstrapper::delete_all(DWORD pid)
{
    WCHAR path[MAX_PATH] = {0};
    if(!get_path(pid, path, MAX_PATH))
        return false;

    global_routing_params* const old_routing_params = this->routing_params;
    bool ret = false;

loop:
    for(global_routing_params* params = this->routing_params, *params_previous = NULL;
        params != NULL;
        params = (global_routing_params*)params->next_global_ptr)
    {
        if(params->module_name_ptr &&
            lstrcmpi((LPWSTR)params->module_name_ptr, path) == 0)
        {
            ret = true;
            if(!params_previous)
            {
                this->routing_params = (global_routing_params*)params->next_global_ptr;
                goto loop;
            }
            else
            {
                params_previous->next_global_ptr = params->next_global_ptr;
                goto loop;
            }
        }

        if(!params_previous)
            params_previous = this->routing_params;
        else
            params_previous = (global_routing_params*)params_previous->next_global_ptr;
    }

    if(ret)
    {
        this->update_save();
        this->routing_params = old_routing_params;
        this->load_local_implicit_params(false);
    }

    return ret;
}
Ejemplo n.º 7
0
void bkp_compose(std::vector<std::string> &tokens){
    std::cout << "backup compose execute\n";
    std::unique_lock<std::mutex> lck(file2);
    std::string author = tokens[1], timestamp = tokens[2];
    std::vector<std::string> msg;
    for(int i = 3; i < tokens.size(); i++){
        msg.push_back(tokens[i]);
    }
    std::ofstream output(get_path(file_id[2]), std::ios::app);
    std::string retval = author + " " + timestamp + " ";
    for(int i = 0; i < msg.size(); i++){
        retval += msg[i];
        if(i != msg.size()-1)
            retval += " ";
    }
    output << "\n" << retval;
    output.close();
}
Ejemplo n.º 8
0
void BC_FileBox::delete_files()
{
// Starting at 1 causes it to ignore what's in the textbox.
	int i = 1;
	char *path;
	FileSystem fs;
	while((path = get_path(i)))
	{
// Not directory.  Remove it.
		if(!fs.is_dir(path))
		{
printf("BC_FileBox::delete_files: removing \"%s\"\n", path);
			remove(path);
		}
		i++;
	}
	refresh();
}
Ejemplo n.º 9
0
static void logvalue(int  p_id,
		     char *sv_name)
{
  char *pipe;
  FILE *fl;

  pipe = get_path(sv_name);
  fl = fopen(pipe, "a");
  fprintf(fl, "%s\n%d\n",
	  sv_name,
	  p_id);
  if (WIFEXITED(p_id))
    fprintf(fl, "1\n%d\n", WEXITSTATUS(p_id));
  if (WIFSIGNALED(p_id))
    fprintf(fl, "0\n1\n%d\n", WTERMSIG(p_id));
  fprintf(fl, "====\n");
  fclose(fl);
}
Ejemplo n.º 10
0
static void		manage_u(t_all *all, char ***e_b, char ***e_d, char ***arg_d)
{
	*e_b = str_array_dup(all->envp, 0);
	if (!ft_strcmp(all->ch_arg[2], "PATH"))
		all->path = NULL;
	if (all->my_envp)
		free_string_array(&all->envp);
	all->envp = str_array_dup(*e_d, 0);
	all->env_list = store_env(*e_d);
	all->cmd = ft_strdup(all->ch_arg[3]);
	all->ch_arg = str_array_dup(*arg_d, 0);
	manage_choice(all);
	if (all->my_envp)
		free_string_array(&all->envp);
	all->envp = str_array_dup(*e_b, 0);
	all->env_list = store_env(all->envp);
	all->path = get_path(all->env_list);
}
Ejemplo n.º 11
0
int read_player(struct player *player, char *name)
{
	char *path;
	int ret;
	FILE *file;

	assert(name != NULL);
	assert(player != NULL);

	if (!(path = get_path(name)))
		return 0;
	if (!(file = fopen(path, "r"))) {
		if (errno == ENOENT)
			return create_player(player, name);
		else
			return perror(path), 0;
	}

	init_player(player, name);

	errno = 0;
	ret = fscanf(file, "%s %d %u\n", player->clan,
	             &player->elo, &player->rank);
	if (ret == EOF && errno != 0) {
		perror(path);
		goto fail;
	} else if (ret == EOF || ret == 0) {
		fprintf(stderr, "%s: Cannot match player clan\n", path);
		goto fail;
	} else if (ret == 1) {
		fprintf(stderr, "%s: Cannot match player rank\n", path);
		goto fail;
	} else if (ret == 2) {
		fprintf(stderr, "%s: Cannot match player score\n", path);
		goto fail;
	}

	fclose(file);
	return 1;

fail:
	fclose(file);
	return 0;
}
Ejemplo n.º 12
0
char * read_whole_file (const char * rel_file_name)
{
    unsigned long s;
    char * contents;
    FILE * f;
    size_t bytes_read;
    int status;

    char * file_name = get_path(rel_file_name);



    f = fopen (file_name, "r");
    if (! f) {
        fprintf (stderr, "Could not open '%s': %s.\n", file_name,
                 strerror (errno));
        exit (EXIT_FAILURE);
    }
    fseek(f,0,SEEK_END);
    s = ftell(f);
    rewind(f);
    contents = malloc (s + 1);
    if (! contents) {
        fprintf (stderr, "Not enough memory.\n");
        exit (EXIT_FAILURE);
    }

    bytes_read = fread (contents, sizeof (char), s, f);
    if (bytes_read != s) {
        fprintf (stderr, "Short read of '%s': expected %lu bytes "
                 "but got %zu: %s.\n", file_name, s, bytes_read,
                 strerror (errno));
        exit (EXIT_FAILURE);
    }
    status = fclose (f);
    if (status != 0) {
        fprintf (stderr, "Error closing '%s': %s.\n", file_name,
                 strerror (errno));
        exit (EXIT_FAILURE);
    }
    contents[s]='\0';
    free(file_name);
    return contents;
}
Ejemplo n.º 13
0
Archivo: env.c Proyecto: ksherlock/gno
char *find_path(const char *arg, char *path) {

	static struct {
		unsigned length;
		char text[PATH_MAX];
	} buffer;

	static FileInfoRecGS dcb = {
		4,
		(GSString255Ptr)&buffer,
		0, 0, 0
	};

	const char *d;
	unsigned len = strlen(arg);

	if (memchr(arg, '/', len)) return arg;
	if (memchr(arg, ':', len)) return arg;


	if (!path) path = get_path();

	// gno uses space as separator, not ':'
	while ((d = strsep(&path, " "))) {
		unsigned l = strlen(d);


		if (l + len + 2 > PATH_MAX) continue;

		memcpy(buffer.text, d, l);
		if (l) buffer.text[l++] = '/';
		memcpy(buffer.text + l, arg, len + 1);
		buffer.length = l + len;

		// check if it exists...
		GetFileInfo(&dcb);
		if (_toolErr) continue;
		// filetype?
		return buffer.text;
	}

	// enoent.
	errx(127, "%s: No such file or directory.", arg);
}
Ejemplo n.º 14
0
int			do_exec(t_av av, t_list *g_env, t_list *l_env)
{
	char	**env;
	char	**path;
	char	*str;

	env = convert_env(g_env, l_env);
	str = get_path(g_env, l_env);
	if (av.arg == NULL)
		av.arg = (char *[]){"", NULL};
	if (execve(av.cmd, av.arg, env) == -1)
	{
		path = get_allpath(av.cmd, str);
		exec_path(av.arg, path, env);
		ft_tabdel(path);
	}
	ft_tabdel(env);
	return (bi_exit(AV_INIT(NULL, NULL, NULL, 1), NULL, NULL));
}
Ejemplo n.º 15
0
bool Target::check_paths(double stamp)
{
    // 因为第一帧选择特征点时,可能某些特征点不在运动目标上,应该去掉 ...
    // FIXME: 仅仅在第5帧时进行检查 ....
    if (layers_.size() != 5) {
        return true;
    }

    // 在第五帧,强制删除距离太小的特征点 ...
    int n = get_path_cnt();
    for (int i = n - 1; i >= 0; i--) {
        PATH path = get_path(i);
        if (distance(path) < min_dis_5frames_) {
            remove_path(i);
        }
    }

    return get_path_cnt() > min_pts_;
}
Ejemplo n.º 16
0
static void init_act(char *svname)
{
  struct sigaction act_term;
  struct sigaction act_kill;
  struct sigaction act_hup;

  get_path(svname);
  act_term.sa_handler = &action_term;
  act_kill.sa_handler = &action_kill;
  act_hup.sa_handler = &action_hup;
  act_term.sa_flags = 0;
  act_kill.sa_flags = 0;
  act_hup.sa_flags = 0;

  if (sigaction(SIGTERM, &act_term, NULL) < 0 ||
      sigaction(SIGUSR1, &act_kill, NULL) < 0 ||
      sigaction(SIGHUP, &act_hup, NULL) < 0)
    perror ("sigaction");
}
Ejemplo n.º 17
0
Path get_path(const hdf5::node::Link &link)
{

  //
  // for a link we can assume that its parent object exists (which must be a
  // group).
  //
  hdf5::node::Group link_parent = link.parent();
  Path path = get_path(link_parent);

  //
  // a link is just a name and thus we cannot make any statement about the
  // particular type of the object referenced by the link. We thus only
  // set the name field of the path element.
  //
  path.push_back({link.path().name(),std::string()});

  return path;
}
Ejemplo n.º 18
0
file_menu::file_menu(CVideo &disp, std::string start_file)
	: menu(disp, empty_string_vector, false),
	  current_dir_(get_path(start_file)),
	  chosen_file_(start_file), last_selection_(-1),
	  type_a_head_(-1)
{
	// If the start file is not a file or directory, use the root.
	if((!file_exists(chosen_file_) && !::is_directory(chosen_file_))
		|| !::is_directory(current_dir_)) {
		current_dir_ = path_delim;
		chosen_file_ = current_dir_;
	}
	// FIXME: quick hack
	// on a high-res screen the initial max_items_onscreen is based
	// on .66 of y dimension, eg. 17 menu items, exceeding the
	// starting box which can only take 13 or so: force it to be smaller
//	set_measurements(400, 384);
	update_file_lists();
}
Ejemplo n.º 19
0
void plugin_system_init(void)
{
    assert (g_module_supported ());

    audgui_init (& api_table, _AUD_PLUGIN_VERSION);

    plugin_registry_load ();

    const char * path = get_path (AUD_PATH_PLUGIN_DIR);

    for (int i = 0; i < ARRAY_LEN (plugin_dir_list); i ++)
    {
        char * dir = filename_build (path, plugin_dir_list[i]);
        scan_plugins (dir);
        str_unref (dir);
    }

    plugin_registry_prune ();
}
Ejemplo n.º 20
0
 vector<string> wordBreak(string s, unordered_set<string> &dict) {
     vector<bool> subword_break (s.size() + 1, false);
     vector<vector<bool> > prev (s.size() + 1, vector<bool> (s.size() + 1, false));
     subword_break[0] = true;
     for (int subword_length = 1; subword_length <= s.size(); ++subword_length) {
         for (int break_at = subword_length - 1; break_at >= 0; --break_at) {
             if (subword_break[break_at] && 
                     isWord(s.substr(break_at, subword_length - break_at), dict)) {
                 subword_break[subword_length] = true;
                 prev[subword_length][break_at] = true;
             }
         }
     }
     
     vector<string> ret;
     vector<string> path;
     get_path(s, prev, s.size(), path, ret);
     return ret;
 }
Ejemplo n.º 21
0
void probe_devices(libusb_context *ctx)
{
	libusb_device **list;
	ssize_t num_devs;
	ssize_t i;

	num_devs = libusb_get_device_list(ctx, &list);
	for (i = 0; i < num_devs; ++i) {
		struct libusb_device_descriptor desc;
		struct libusb_device *dev = list[i];

		if (match_path != NULL && strcmp(get_path(dev),match_path) != 0)
			continue;
		if (libusb_get_device_descriptor(dev, &desc))
			continue;
		probe_configuration(dev, &desc);
	}
	libusb_free_device_list(list, 0);
}
Ejemplo n.º 22
0
int
fchmodat(int fd, const char* path, mode_t mode, int flag)
{
	if ((flag & AT_SYMLINK_NOFOLLOW) == 0 && flag != 0) {
		// invalid flag
		errno = EINVAL;
		return -1;
	}

	if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
		// call chmod() ignoring fd
		if ((flag & AT_SYMLINK_NOFOLLOW) != 0) {
			// fake lchmod() with open() and fchmod()
			int symlinkfd = open(path, O_RDONLY | O_SYMLINK);
			int status = fchmod(symlinkfd, mode);
			close(symlinkfd);
			return status;
		} else
			return chmod(path, mode);
	}

	if (fd < 0) {
		// Invalid file descriptor
		errno = EBADF;
		return -1;
	}

	char fullPath[MAXPATHLEN];
	if (get_path(fd, path, fullPath) < 0)
		return -1;

	int status;
	if ((flag & AT_SYMLINK_NOFOLLOW) != 0) {
		// fake lchmod() with open() and fchmod()
		int fullfd = open(fullPath, O_RDONLY | O_SYMLINK);
		status = fchmod(fullfd, mode);
		close(fullfd);
	} else
		status = chmod(fullPath, mode);

	return status;
}
Ejemplo n.º 23
0
void save_all_bouquets(){
	FILE *stream;
	GNode *node_bouquet;
	GNode *node_channel;
	bouquetEntry *bouquet;
	channelEntry *channel;
	gchar txtBuffer[100];

	if (!(stream = fopen(get_path (ZAPIT_BOUQ_NEW), "wb"))){
		GtkWidget* dialog;
		dialog = gtk_message_dialog_new (NULL,0, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
			txtIn(_("could not create bouquets-file")));
		center_window(GTK_WINDOW(dialog));
		gtk_dialog_run (GTK_DIALOG (dialog));
		gtk_widget_destroy (dialog);
		return;
	}
	fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",stream);
	fputs("<zapit>\n",stream);	

	node_bouquet = g_node_first_child(MW_GET("RIGHT_NODE_ROOT"));
	while (node_bouquet){
		bouquet = node_bouquet->data;
		node_channel = g_node_first_child (node_bouquet);
		if (node_channel)	{ // Bouquet enthält Sender.
			sprintf(txtBuffer,"\t<Bouquet name=\"%s\" hidden=\"%d\" locked=\"%d\">\n",
				ascToXML(bouquet->bouquetName), bouquet->hidden, bouquet->locked);
			fputs(txtBuffer,stream);
			while (node_channel){
				channel = (channelEntry *) node_channel->data;
				sprintf(txtBuffer,"\t\t<channel serviceID=\"%.4x\" name=\"%s\" onid=\"%.4x\"/>\n",
					channel->serviceID, ascToXML(channel->channelName), channel->onid);
				fputs(txtBuffer,stream);
				node_channel = node_channel ->next;
			}
			fputs("\t</Bouquet>\n",stream);
		}
		node_bouquet = node_bouquet->next;
	}
	fputs("</zapit>\n",stream);	
	fclose(stream);
}
Ejemplo n.º 24
0
static svn_error_t *
delete_entry(const char *path,
             svn_revnum_t revision,
             void *parent_baton,
             apr_pool_t *scratch_pool)
{
  struct dir_baton_t *pb = parent_baton;
  struct edit_baton_t *eb = pb->eb;
  const char *local_abspath;

  SVN_ERR(get_path(&local_abspath,
                   eb->anchor_abspath, path, scratch_pool));
  SVN_ERR(svn_wc_delete4(eb->wc_ctx, local_abspath,
                         FALSE /*keep_local*/,
                         TRUE /*delete_unversioned*/,
                         NULL, NULL, /*cancellation*/
                         eb->notify_func, eb->notify_baton, scratch_pool));

  return SVN_NO_ERROR;
}
Ejemplo n.º 25
0
ssize_t
readlinkat(int fd, const char *path, char *buffer, size_t bufferSize)
{
	if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
		// call readlink() ignoring fd
		return readlink(path, buffer, bufferSize);
	}

	if (fd < 0) {
		// Invalid file descriptor
		errno = EBADF;
		return -1;
	}

	char fullPath[MAXPATHLEN];
	if (get_path(fd, path, fullPath) < 0)
		return -1;

	return readlink(fullPath, buffer, bufferSize);
}
Ejemplo n.º 26
0
double Camera::extract_near_z() const
{
    const double DefaultNearZ = -0.001;         // in meters

    double near_z = m_params.get_optional<double>("near_z", DefaultNearZ);

    if (near_z > 0.0)
    {
        RENDERER_LOG_ERROR(
            "while defining camera \"%s\": invalid near-Z value \"%f\", near-Z values must be negative or zero; "
            "using default value \"%f\".",
            get_path().c_str(),
            near_z,
            DefaultNearZ);

        near_z = DefaultNearZ;
    }

    return near_z;
}
Ejemplo n.º 27
0
int
futimesat(int fd, const char *path, const struct timeval times[2])
{
	if (fd == AT_FDCWD || (path != NULL && path[0] == '/')) {
		// call utimes() ignoring fd
		return utimes(path, times);
	}

	if (fd < 0) {
		// Invalid file descriptor
		errno = EBADF;
		return -1;
	}

	char fullPath[MAXPATHLEN];
	if (get_path(fd, path, fullPath) < 0)
		return -1;

	return utimes(fullPath, times);
}
Ejemplo n.º 28
0
Archivo: main.c Proyecto: YliesC/42sh
int		my_read(t_utils *utils)
{
  char		*buffer;

  signal(SIGINT, &my_handler);
  create_prompt(utils);
  while ((buffer = my_readline(g_prompt, utils)))
    {
      if (main_loop(buffer, utils) == 42)
	{
	  free(buffer);
	  return (42);
	}
      create_prompt(utils);
      get_path(utils);
      free(buffer);
    }
  write(1, "\n", 1);
  return (0);
}
Ejemplo n.º 29
0
void init_items(void)
{
	uint32 i = 0;
	char *path;

	item_array = (item_t *)calloc(MAX_ITEMS, sizeof(item_t));

	for(i = 0; i < MAX_ITEMS; i++){
		item_array[i].name = (char *)calloc(MAX_NAME_LENGTH, sizeof(char));

		path = get_path(ITEM_PATH, i, FILE_ENDING);

		check_dir(ITEM_PATH);

		if(file_readable(path))
			read_item(path,i);
		else
			write_item(path,i);
	}
}
Ejemplo n.º 30
0
Archivo: mu-msg.c Proyecto: akonring/mu
/* for some data, we need to read the message file from disk */
gboolean
mu_msg_load_msg_file (MuMsg *self, GError **err)
{
	const char *path;

	g_return_val_if_fail (self, FALSE);

	if (self->_file)
		return TRUE; /* nothing to do */

	if (!(path = get_path (self))) {
		mu_util_g_set_error (err, MU_ERROR_INTERNAL,
				     "cannot get path for message");
		return FALSE;
	}

	self->_file = mu_msg_file_new (path, NULL, err);

	return  (self->_file != NULL);
}