mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
55 lines
914 B
C
55 lines
914 B
C
|
/*
|
||
|
* Implementation of Filename for Windows.
|
||
|
*/
|
||
|
|
||
|
#include "putty.h"
|
||
|
|
||
|
Filename *filename_from_str(const char *str)
|
||
|
{
|
||
|
Filename *ret = snew(Filename);
|
||
|
ret->path = dupstr(str);
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
Filename *filename_copy(const Filename *fn)
|
||
|
{
|
||
|
return filename_from_str(fn->path);
|
||
|
}
|
||
|
|
||
|
const char *filename_to_str(const Filename *fn)
|
||
|
{
|
||
|
return fn->path;
|
||
|
}
|
||
|
|
||
|
bool filename_equal(const Filename *f1, const Filename *f2)
|
||
|
{
|
||
|
return !strcmp(f1->path, f2->path);
|
||
|
}
|
||
|
|
||
|
bool filename_is_null(const Filename *fn)
|
||
|
{
|
||
|
return !*fn->path;
|
||
|
}
|
||
|
|
||
|
void filename_free(Filename *fn)
|
||
|
{
|
||
|
sfree(fn->path);
|
||
|
sfree(fn);
|
||
|
}
|
||
|
|
||
|
void filename_serialise(BinarySink *bs, const Filename *f)
|
||
|
{
|
||
|
put_asciz(bs, f->path);
|
||
|
}
|
||
|
Filename *filename_deserialise(BinarySource *src)
|
||
|
{
|
||
|
return filename_from_str(get_asciz(src));
|
||
|
}
|
||
|
|
||
|
char filename_char_sanitise(char c)
|
||
|
{
|
||
|
if (strchr("<>:\"/\\|?*", c))
|
||
|
return '.';
|
||
|
return c;
|
||
|
}
|