Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Borghetti <bdiego@gmail.com>2009-02-09 10:15:22 +0300
committerDiego Borghetti <bdiego@gmail.com>2009-02-09 10:15:22 +0300
commitb9063b27a9376ca276cb80f692ef8fa923a966a7 (patch)
treeb70345fb669b481c1cf1bdec875e876d2d46f2e3 /source/blender/blenfont/intern/blf_dir.c
parent9dec5e8fa3a214da7ad406265204411aabda3c30 (diff)
Just commit so I can continue tomorrow from work.
All the code have #if 0 / #endif so nothing to worry about.
Diffstat (limited to 'source/blender/blenfont/intern/blf_dir.c')
-rw-r--r--source/blender/blenfont/intern/blf_dir.c171
1 files changed, 171 insertions, 0 deletions
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
new file mode 100644
index 00000000000..2472d36a1d8
--- /dev/null
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -0,0 +1,171 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#if 0
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+
+#include "BKE_utildefines.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_linklist.h" /* linknode */
+#include "BLI_string.h"
+
+#include "blf_internal_types.h"
+
+static ListBase global_font_dir= { NULL, NULL };
+
+DirBLF *blf_dir_find(const char *path)
+{
+ DirBLF *p;
+
+ p= global_font_dir.first;
+ while (p) {
+ if (!strcmp(p->path, path))
+ return(p);
+ p= p->next;
+ }
+ return(NULL);
+}
+
+void BLF_dir_add(const char *path)
+{
+ DirBLF *dir;
+
+ dir= blf_dir_find(path);
+ if (dir) /* already in the list ? just return. */
+ return;
+
+ dir= (DirBLF *)MEM_mallocN(sizeof(DirBLF), "BLF_dir_add");
+ dir->path= BLI_strdup(path);
+ BLI_addhead(&global_font_dir, dir);
+}
+
+void BLF_dir_rem(const char *path)
+{
+ DirBLF *dir;
+
+ dir= blf_dir_find(path);
+ if (dir) {
+ BLI_remlink(&global_font_dir, dir);
+ MEM_freeN(dir->path);
+ MEM_freeN(dir);
+ }
+}
+
+char **BLF_dir_get(int *ndir)
+{
+ DirBLF *p;
+ char **dirs;
+ char *path;
+ int i, count;
+
+ count= BLI_countlist(&global_font_dir);
+ if (!count)
+ return(NULL);
+
+ dirs= (char **)MEM_mallocN(sizeof(char *) * count, "BLF_dir_get");
+ p= global_font_dir.first;
+ i= 0;
+ while (p) {
+ path= BLI_strdup(p->path);
+ dirs[i]= path;
+ p= p->next;
+ }
+ *ndir= i;
+ return(dirs);
+}
+
+void BLF_dir_free(char **dirs, int count)
+{
+ char *path;
+ int i;
+
+ for (i= 0; i < count; i++) {
+ path= dirs[i];
+ MEM_freeN(path);
+ }
+ MEM_freeN(dirs);
+}
+
+char *blf_dir_search(char *file)
+{
+ DirBLF *dir;
+ char full_path[FILE_MAXDIR+FILE_MAXFILE];
+ char *s;
+
+ dir= global_font_dir.first;
+ s= NULL;
+ while (dir) {
+ BLI_join_dirfile(full_path, dir->path, file);
+ if (BLI_exist(full_path)) {
+ s= (char *)MEM_mallocN(strlen(full_path)+1,"blf_dir_search");
+ strcpy(s, full_path);
+ break;
+ }
+ dir= dir->next;
+ }
+
+ if (!s) {
+ /* check the current directory, why not ? */
+ if (BLI_exist(file))
+ s= BLI_strdup(file);
+ }
+
+ return(s);
+}
+
+int blf_dir_split(const char *str, char *file, int *size)
+{
+ char *s, i, len;
+
+ /* Window, Linux or Mac, this is always / */
+ s= strrchr(str, '/');
+ if (s) {
+ len= s - str;
+ for (i= 0; i < len; i++)
+ file[i]= str[i];
+
+ file[i]= '.';
+ file[i+1]= 't';
+ file[i+2]= 't';
+ file[i+3]= 'f';
+ file[i+4]= '\0';
+ s++;
+ *size= atoi(s);
+ return(1);
+ }
+ return(0);
+}
+
+#endif /* zero!! */