mkdir exportdir's parent, if necessary
Tux Paint's export features will fail if the parent of the export directory didn't exist. e.g., using the default (either via XDG or hard-coded fallback) of "~/Pictures/TuxPaint/", Tux Paint could not export if "~/Pictures/" didn't exist yet. It will now try to mkdir it as well. h/t Tim Dickson Updated OPTIONS documents to explain this. Also, documenting --exportdir in manpage (was missing!)
This commit is contained in:
parent
c2a4b9862a
commit
c97932606f
9 changed files with 74 additions and 20 deletions
|
|
@ -8,7 +8,7 @@ http://www.tuxpaint.org/
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
2021.January.10 (0.9.26)
|
2021.January.13 (0.9.26)
|
||||||
* New Magic Tools:
|
* New Magic Tools:
|
||||||
----------------
|
----------------
|
||||||
* Pixels
|
* Pixels
|
||||||
|
|
@ -27,6 +27,15 @@ $Id$
|
||||||
* Documented how to build Tux Paint using old macOS
|
* Documented how to build Tux Paint using old macOS
|
||||||
Mark K. Kim <markuskimius@gmail.com>
|
Mark K. Kim <markuskimius@gmail.com>
|
||||||
|
|
||||||
|
* Other Improvements
|
||||||
|
------------------
|
||||||
|
* If parent of export directory doesn't exist, Tux Paint will
|
||||||
|
try to create it as well.
|
||||||
|
(Only one level up; e.g., with an export location like
|
||||||
|
/path/to/Pictures/TuxPaint/, it will try to create
|
||||||
|
/path/to/Pictures/ if it doesn't exist, but not its parents).
|
||||||
|
h/t Tim Dickson
|
||||||
|
|
||||||
2020.December.27 (0.9.25)
|
2020.December.27 (0.9.25)
|
||||||
* New Features
|
* New Features
|
||||||
------------
|
------------
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
Options Documentation
|
Options Documentation
|
||||||
|
|
||||||
Copyright (c) 2002-2020 by various contributors; see AUTHORS.txt
|
Copyright (c) 2002-2021 by various contributors; see AUTHORS.txt
|
||||||
http://www.tuxpaint.org/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
December 27, 2020
|
December 27, 2020
|
||||||
|
|
@ -607,9 +607,14 @@ Windows Users
|
||||||
Note: When the defaults are used, a new "TuxPaint" subdirectory
|
Note: When the defaults are used, a new "TuxPaint" subdirectory
|
||||||
will be created and used. (e.g., "~/Pictures/TuxPaint") When the
|
will be created and used. (e.g., "~/Pictures/TuxPaint") When the
|
||||||
"--exportdir" option is used, the exact path specified will be
|
"--exportdir" option is used, the exact path specified will be
|
||||||
used (no "TuxPaint" subdirectory is created). It is expected
|
used (no "TuxPaint" subdirectory is created).
|
||||||
that the parent directory exists. (The directory itself will be
|
|
||||||
created, if it doesn't.)
|
The directory itself (e.g., "~/Pictures/TuxPaint") will be
|
||||||
|
created, if it doesn't exist.
|
||||||
|
|
||||||
|
If the parent directory (e.g., "~/Pictures") also does not
|
||||||
|
exist, Tux Paint will attempt to create it as well (but not any
|
||||||
|
directories higher than that).
|
||||||
|
|
||||||
Example: exportdir=/home/penguin/TuxPaintExports
|
Example: exportdir=/home/penguin/TuxPaintExports
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
Copyright 2002-2021 by various contributors; see AUTHORS.txt
|
Copyright 2002-2021 by various contributors; see AUTHORS.txt
|
||||||
http://www.tuxpaint.org/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
June 14, 2002 - January 6, 2021
|
June 14, 2002 - January 13, 2021
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Copyright (c) 2002-2020 by various contributors; see
|
Copyright (c) 2002-2021 by various contributors; see
|
||||||
AUTHORS.txt<br>
|
AUTHORS.txt<br>
|
||||||
<a href=
|
<a href=
|
||||||
"http://www.tuxpaint.org/">http://www.tuxpaint.org/</a>
|
"http://www.tuxpaint.org/">http://www.tuxpaint.org/</a>
|
||||||
|
|
@ -1274,9 +1274,16 @@
|
||||||
and used. (e.g., "<code>~/Pictures/TuxPaint</code>")
|
and used. (e.g., "<code>~/Pictures/TuxPaint</code>")
|
||||||
When the "<code>--exportdir</code>" option is used, the
|
When the "<code>--exportdir</code>" option is used, the
|
||||||
exact path specified will be used (no
|
exact path specified will be used (no
|
||||||
"<code>TuxPaint</code>" subdirectory is created). It is
|
"<code>TuxPaint</code>" subdirectory is created).
|
||||||
expected that the parent directory exists. (The
|
</p>
|
||||||
directory itself will be created, if it doesn't.)
|
<p>
|
||||||
|
The directory itself (e.g., "<code>~/Pictures/TuxPaint</code>")
|
||||||
|
will be created, if it doesn't exist.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If the <em>parent</em> directory (e.g., "<code>~/Pictures</code>")
|
||||||
|
also does not exist, Tux Paint will attempt to create it
|
||||||
|
as well (but not any directories higher than that).
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
June 14, 2002 - January 6, 2021
|
June 14, 2002 - January 13, 2021
|
||||||
</p>
|
</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
get_fname.c
|
get_fname.c
|
||||||
|
|
||||||
Copyright (c) 2009 - 2020
|
Copyright (c) 2009 - 2021
|
||||||
http://www.tuxpaint.org/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
|
@ -57,6 +57,11 @@
|
||||||
and easily-accessible place for end users to retrieve the exports.
|
and easily-accessible place for end users to retrieve the exports.
|
||||||
|
|
||||||
The defaults may be overridden with the "--exportdir" option.
|
The defaults may be overridden with the "--exportdir" option.
|
||||||
|
|
||||||
|
* DIR_EXPORT_PARENT: The parent of the directory
|
||||||
|
specified by DIR_EXPORT. (e.g., if /home/username/Pictures/TuxPaint/
|
||||||
|
is our export dir., we may need to make .../Pictures first,
|
||||||
|
the first time we export something.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -88,7 +93,7 @@ char *get_fname(const char *const name, int kind)
|
||||||
dir = savedir;
|
dir = savedir;
|
||||||
} else if (kind == DIR_DATA) {
|
} else if (kind == DIR_DATA) {
|
||||||
dir = datadir;
|
dir = datadir;
|
||||||
} else if (kind == DIR_EXPORT) {
|
} else if (kind == DIR_EXPORT || kind == DIR_EXPORT_PARENT) {
|
||||||
dir = exportdir;
|
dir = exportdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,6 +102,20 @@ char *get_fname(const char *const name, int kind)
|
||||||
dir, (*name) ? '/' : '\0', /* Some mkdir()'s don't like trailing slashes */
|
dir, (*name) ? '/' : '\0', /* Some mkdir()'s don't like trailing slashes */
|
||||||
name);
|
name);
|
||||||
|
|
||||||
|
if (kind == DIR_EXPORT_PARENT) {
|
||||||
|
int len, i, stop;
|
||||||
|
|
||||||
|
stop = -1;
|
||||||
|
len = strlen(f);
|
||||||
|
for (i = len - 1; i >= 0 && stop == -1; i--) {
|
||||||
|
if (f[i] == '/')
|
||||||
|
stop = i;
|
||||||
|
}
|
||||||
|
if (stop != -1) {
|
||||||
|
f[stop] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return strdup(f);
|
return strdup(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
get_fname.h
|
get_fname.h
|
||||||
|
|
||||||
Copyright (c) 2009 - July 25, 2020
|
Copyright (c) 2009 - January 13, 2021
|
||||||
http://www.tuxpaint.org/
|
http://www.tuxpaint.org/
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
|
@ -34,7 +34,8 @@ enum
|
||||||
/* (See get_fname.c for details) */
|
/* (See get_fname.c for details) */
|
||||||
DIR_SAVE,
|
DIR_SAVE,
|
||||||
DIR_DATA,
|
DIR_DATA,
|
||||||
DIR_EXPORT
|
DIR_EXPORT,
|
||||||
|
DIR_EXPORT_PARENT
|
||||||
};
|
};
|
||||||
|
|
||||||
char *get_fname(const char *const name, int kind);
|
char *get_fname(const char *const name, int kind);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.\" tuxpaint.1 - 2020.12.27
|
.\" tuxpaint.1 - 2021.01.13
|
||||||
.TH TUXPAINT 1 "27 December 2020" "0.9.26" "Tux Paint"
|
.TH TUXPAINT 1 "13 January 2021" "0.9.26" "Tux Paint"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
tuxpaint -- "Tux Paint", a drawing program for young children.
|
tuxpaint -- "Tux Paint", a drawing program for young children.
|
||||||
|
|
||||||
|
|
@ -131,6 +131,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
|
||||||
.br
|
.br
|
||||||
[\-\-savedir \fIDIR\fP]
|
[\-\-savedir \fIDIR\fP]
|
||||||
.br
|
.br
|
||||||
|
[\-\-exportdir \fIDIR\fP]
|
||||||
|
.br
|
||||||
[\-\-datadir \fIDIR\fP]
|
[\-\-datadir \fIDIR\fP]
|
||||||
.br
|
.br
|
||||||
[\-\-saveover]
|
[\-\-saveover]
|
||||||
|
|
@ -484,7 +486,11 @@ Use the \fIalllocalefonts\fP option to load all such fonts, for use in the
|
||||||
|
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-\-savedir \fIDIR\fP
|
.B \-\-savedir \fIDIR\fP
|
||||||
Specify where \fITux Paint\fP should save files.
|
Specify where \fITux Paint\fP should save and load its drawings.
|
||||||
|
|
||||||
|
.TP 8
|
||||||
|
.B \-\-exportdir \fIDIR\fP
|
||||||
|
Specify where \fITux Paint\fP should export drawings and animations.
|
||||||
|
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-\-datadir \fIDIR\fP
|
.B \-\-datadir \fIDIR\fP
|
||||||
|
|
|
||||||
|
|
@ -25963,9 +25963,16 @@ static char * get_export_filepath(const char * ext) {
|
||||||
|
|
||||||
|
|
||||||
/* Make sure the export dir exists */
|
/* Make sure the export dir exists */
|
||||||
if (!make_directory(DIR_EXPORT, "", "Can't create export directory (E016)"))
|
if (!make_directory(DIR_EXPORT, "", "Can't create export directory; will try to make its parent (E016)"))
|
||||||
{
|
{
|
||||||
return NULL;
|
/* See if perhaps we need to try and make its parent directory first? */
|
||||||
|
if (make_directory(DIR_EXPORT_PARENT, "", "Can't create export directory parent (E016b)")) {
|
||||||
|
if (!make_directory(DIR_EXPORT, "", "Can't create export directory (E016c)")) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a unique filename, within that dir */
|
/* Create a unique filename, within that dir */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue