32
** Open tempfile cached by IO_CACHE
33
** Should be used when no seeks are done (only reinit_io_buff)
34
** Return false if cache is inited ok
35
** The actual file is created when the IO_CACHE buffer gets filled
36
** If dir is not given, use TMPDIR.
32
** Open tempfile cached by st_io_cache
33
** Should be used when no seeks are done (only reinit_io_buff)
34
** Return false if cache is inited ok
35
** The actual file is created when the st_io_cache buffer gets filled
36
** If dir is not given, use TMPDIR.
39
bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
40
size_t cache_size, myf cache_myflags)
39
bool open_cached_file(st_io_cache *cache, const char *dir_arg, const char *prefix_arg,
40
size_t cache_size_arg, myf cache_myflags)
42
cache->dir= dir ? strdup(dir) : (char*) 0;
43
cache->prefix= (prefix ? strdup(prefix) :
42
cache->dir= dir_arg ? strdup(dir_arg) : (char*) 0;
43
cache->prefix= (prefix_arg ? strdup(prefix_arg) : (char*) 0);
45
45
if ((cache->dir == NULL) || (cache->prefix == NULL))
48
cache->buffer=0; /* Mark that not open */
49
if (!init_io_cache(cache,-1,cache_size,WRITE_CACHE,0L,0,
50
MYF(cache_myflags | MY_NABP)))
49
cache->buffer= 0; /* Mark that not open */
50
if (not cache->init_io_cache(-1, cache_size_arg,WRITE_CACHE,0L,0, MYF(cache_myflags | MY_NABP)))
55
55
free(cache->prefix);
59
/* Create the temporary file */
60
/* Create the temporary file */
61
bool real_open_cached_file(IO_CACHE *cache)
62
bool st_io_cache::real_open_cached_file()
63
64
char name_buff[FN_REFLEN];
65
if ((cache->file=create_temp_file(name_buff, cache->dir, cache->prefix, MYF(MY_WME))) >= 0)
66
if ((file= create_temp_file(name_buff, dir, prefix, MYF(MY_WME))) >= 0)
68
68
my_delete(name_buff,MYF(MY_WME | ME_NOINPUT));
74
void close_cached_file(IO_CACHE *cache)
76
void st_io_cache::close_cached_file()
76
if (my_b_inited(cache))
78
if (my_b_inited(this))
79
cache->file= -1; /* Don't flush data */
80
(void) end_io_cache(cache);
81
file= -1; /* Don't flush data */
82
(void) end_io_cache();
83
(void) my_close(file,MYF(0));
85
(void) my_close(_file, MYF(0));
84
86
#ifdef CANT_DELETE_OPEN_FILES
87
(void) my_delete(cache->file_name,MYF(MY_WME | ME_NOINPUT));
88
free(cache->file_name);
89
(void) my_delete(file_name, MYF(MY_WME | ME_NOINPUT));
98
99
} /* namespace internal */