mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
another attempt to fix embedded-dot problem
This commit is contained in:
parent
07ab48032d
commit
32348d7410
@ -193,19 +193,25 @@ void ImageFile::
|
|||||||
set_filename(const string &dirname, const string &basename) {
|
set_filename(const string &dirname, const string &basename) {
|
||||||
_filename = Filename(dirname, basename);
|
_filename = Filename(dirname, basename);
|
||||||
|
|
||||||
if (_properties._alpha_type != (PNMFileType *)NULL) {
|
// Since we use set_extension() here, if the file already contains a
|
||||||
_alpha_filename =
|
// filename extension it will be lost.
|
||||||
_filename.get_fullpath() + "_a." +
|
|
||||||
_properties._alpha_type->get_suggested_extension();
|
// It is particularly important to note that a single embedded dot
|
||||||
}
|
// will appear to begin a filename extension, so if the filename
|
||||||
|
// does *not* contain an extension, but does contain an embedded
|
||||||
|
// dot, the filename will be truncated at that dot. It is therefore
|
||||||
|
// important that the supplied basename always contains either an
|
||||||
|
// extension or a terminating dot.
|
||||||
|
|
||||||
if (_properties._color_type != (PNMFileType *)NULL) {
|
if (_properties._color_type != (PNMFileType *)NULL) {
|
||||||
// We shouldn't use _filename.set_extension(), because that may
|
_filename.set_extension
|
||||||
// inadvertently truncate the filename if it already includes a
|
(_properties._color_type->get_suggested_extension());
|
||||||
// dot.
|
}
|
||||||
_filename =
|
|
||||||
_filename.get_fullpath() + "." +
|
if (_properties._alpha_type != (PNMFileType *)NULL) {
|
||||||
_properties._color_type->get_suggested_extension();
|
_alpha_filename = _filename.get_fullpath_wo_extension() + "_a";
|
||||||
|
_alpha_filename.set_extension
|
||||||
|
(_properties._alpha_type->get_suggested_extension());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +175,12 @@ PaletteImage(PalettePage *page, int index) :
|
|||||||
_got_image = false;
|
_got_image = false;
|
||||||
|
|
||||||
ostringstream name;
|
ostringstream name;
|
||||||
|
// We must end the basename with a dot, so that it does not appear
|
||||||
|
// to have a filename extension. Otherwise, an embedded dot in the
|
||||||
|
// group's name would make everything following appear to be an
|
||||||
|
// extension, which would get lost in the set_filename() call.
|
||||||
name << page->get_group()->get_name() << "_palette_"
|
name << page->get_group()->get_name() << "_palette_"
|
||||||
<< page->get_name() << "_" << index + 1;
|
<< page->get_name() << "_" << index + 1 << ".";
|
||||||
|
|
||||||
_basename = name.str();
|
_basename = name.str();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user