summaryrefslogtreecommitdiff
path: root/fluid/tools/filename.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2025-03-16 17:16:12 -0400
committerGitHub <noreply@github.com>2025-03-16 17:16:12 -0400
commit51a55bc73660f64e8f4b32b8b4d3858f2a786f7b (patch)
tree122ad9f838fcf8f61ed7cf5fa031e8ed69817e10 /fluid/tools/filename.cxx
parent13a7073a1e007ce5b71ef70bced1a9b15158820d (diff)
Fluid: restructuring and rejuvenation of the source code.
* Add classes for application and project * Removed all globals from Fluid.h * Extracting args and project history into their own classes * Moving globals into Application class * Initialize values inside headers for some classes. * Undo functionality wrapped in a class inside Project. * File reader and writer are now linked to a project. * Avoid global project access * Nodes (former Types) will be managed by a new Tree class. * Removed static members (hidden globals) form Node/Fl_Type. * Adding Tree iterator. * Use nullptr instead of 0, NULL, or 0L * Renamed Fl_..._Type to ..._Node, FL_OVERRIDE -> override * Renaming ..._type to ...::prototype * Splitting Widget Panel into multiple files. * Moved callback code into widget panel file. * Cleaning up Fluid_Image -> Image_asset * Moving Fd_Snap_Action into new namespace fld::app::Snap_Action etc. * Moved mergeback into proj folder. * `enum ID` is now `enum class Type`.
Diffstat (limited to 'fluid/tools/filename.cxx')
-rw-r--r--fluid/tools/filename.cxx32
1 files changed, 30 insertions, 2 deletions
diff --git a/fluid/tools/filename.cxx b/fluid/tools/filename.cxx
index bbd749ce1..a5d6e22b3 100644
--- a/fluid/tools/filename.cxx
+++ b/fluid/tools/filename.cxx
@@ -1,7 +1,7 @@
//
-// Filename expansion routines for the Fast Light Tool Kit (FLTK).
+// Filename handling code for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2023 by Bill Spitzak and others.
+// Copyright 1998-2025 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -95,3 +95,31 @@ std::string fl_filename_shortened(const std::string &filename, int max_chars) {
return homed_filename;
}
}
+
+/**
+ Make sure that a path name ends with a forward slash.
+ \param[in] str directory or path name
+ \return a new string, ending with a '/'
+ */
+std::string fld::end_with_slash(const std::string &str) {
+ char last = str[str.size()-1];
+ if (last !='/' && last != '\\')
+ return str + "/";
+ else
+ return str;
+}
+
+/**
+ Replace Windows '\\' directory separator with UNix '/' separators.
+ \param[in] fn a file path in Unix or Windows format
+ \return a copy of the file path in Unix format.
+ */
+std::string fld::fix_separators(const std::string &fn) {
+ std::string ret = fn;
+ for (size_t i=0; i<ret.size(); ++i) {
+ if (ret[i] == '\\') {
+ ret[i] = '/';
+ }
+ }
+ return ret;
+}