TheBoussinesqModel
3.2.1
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
get_filenames.c
Go to the documentation of this file.
1
2
/* KeyPalette MANAGES THE I/O FILES OF A MODEL
3
KeyPalette Version 0.9375 KMackenzie
4
5
file get_filenames.c
6
7
Copyright, 2009 Emanuele Cordano and Riccardo Rigon
8
9
This file is part of KeyPalette.
10
KeyPalette is free software: you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation, either version 3 of the License, or
13
(at your option) any later version.
14
15
KeyPalette is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
#include "
turtle.h
"
25
#include "
t_io.h
"
26
#include "
key.palette.h
"
27
#include "
get_filenames.h
"
28
#define INIT ".init"
29
#define INPTS ".inpts"
30
31
32
#define NOFILE_NAME join_strings(WORKING_DIRECTORY,"MISSING_FILE")
33
34
STRINGBIN
*
get_filenames_from_keys
(
char
*
WORKING_DIRECTORY
,
char
*program,
short
print){
35
/*
36
*
37
* \author Emanuele Cordano
38
*
39
* \date Dec 2008
40
*
41
*\param WORKING_DIRECTORY (char *) - working directory where *.init and *.inpts are contained
42
*\param program (char *) - name of the program
43
*\param print (short) - flag for verdose mode
44
*
45
*\return a stringbin with filenames
46
*
47
*/
48
49
char
*keyfile, *inptsfile;
50
KEYWORDS
*keywords_file;
51
STRINGBIN
*files;
52
FILE *fkey,*finpts;
53
STRINGBIN
*names;
54
short
ik;
55
char
*pinit,*pinpts, *nofilename;
56
nofilename=
NOFILE_NAME
;
/* allocated with joint-strings */
57
if
(print==1) printf(
"\nWORKING DIRECTORY: %s"
,WORKING_DIRECTORY);
58
/* READ FILENAMES with KeyPalette */
59
pinit=
join_strings
(program,
INIT
);
60
keyfile=
join_strings
(WORKING_DIRECTORY,pinit);
61
free(pinit);
62
pinpts=
join_strings
(program,
INPTS
);
63
inptsfile=
join_strings
(WORKING_DIRECTORY,pinpts);
64
free(pinpts);
65
/* GET KEYWORD FOR EACH FILES */
66
fkey=
t_fopen
(keyfile,
"r"
);
67
ik=
read_index
(fkey,print);
/* read file keywords string */
68
keywords_file=
read_keywords
(fkey,print);
/* read keywords for each file */
69
t_fclose
(fkey);
70
if
(print==1)
write_keywords
(keywords_file);
71
72
73
74
/* GET FILENAMES */
75
finpts=
t_fopen
(inptsfile,
"r"
);
76
ik=
read_index
(finpts,print);
77
names=
read_names
(finpts,keywords_file->
names
,nofilename,print);
78
files=
join_path_to_stringbin
(WORKING_DIRECTORY,names,
"/"
);
79
free_stringbin
(names);
80
81
if
(print==1)
write_read_filenames
(files,keywords_file->
comments
);
82
83
t_fclose
(finpts);
84
free(nofilename);
85
free(keyfile);
86
free(inptsfile);
87
free_keywords
(keywords_file);
88
89
return
files;
90
}
91
KeyPalette
get_filenames.c
Generated on Wed Jun 5 2013 10:08:45 for TheBoussinesqModel by
1.8.4