Commit Graph

30 Commits

Author SHA1 Message Date
Mark Olesen
d5cdc60a54 BUG: processorMeshes removeFiles does not remove collated (fixes #2607)
ENH: extend rmDir to handle removal of empty directories only

- recursively remove directories that only contain other directories
  but no other contents. Treats dead links as non-content.
2022-10-11 17:58:22 +02:00
Mark Olesen
779a2ca084 ENH: adjust fileName methods for similarity to std::filesystem::path
- stem(), replace_name(), replace_ext(), remove_ext() etc

- string::contains() method - similar to C++23 method

  Eg,
      if (keyword.contains('/')) ...
  vs
      if (keyword.find('/') != std::string::npos) ...
2022-10-11 17:58:22 +02:00
Mark Olesen
62ec2f2ddf COMP: deprecate domainName and full hostName (#2280)
- unused in regular OpenFOAM code
- POSIX version uses deprecated gethostbyname()
- Windows version never worked

COMP: localize, noexcept on internal OSspecific methods

STYLE: support fileName::Type SYMLINK and LINK as synonyms
2022-02-10 16:46:12 +01:00
Mark Olesen
851be8ea33 ENH: use consistent naming when toggling exception throwing on/off 2021-11-02 21:14:41 +01:00
Mark Olesen
7ad75fa18e ENH: add single-parameter PtrListOps::names (ie, no name filtering)
ENH: adjust fileName component method

- the location \c npos returns the last component
2021-10-12 10:11:05 +02:00
Mark Olesen
b060378dca ENH: improve consistency of fileName handling windows/non-windows (#2057)
- wrap command-line retrieval of fileName with an implicit validate.

  Instead of this:
      fileName input(args[1]);
      fileName other(args["someopt"]);

  Now use this:
      auto input = args.get<fileName>(1);
      auto other = args.get<fileName>("someopt");

  which adds a fileName::validate on the inputs

  Because of how it is implemented, it will automatically also apply
  to argList getOrDefault<fileName>, readIfPresent<fileName> etc.

- adjust fileName::validate and clean to handle backslash conversion.
  This makes it easier to ensure that path names arising from MS-Windows
  are consistently handled internally.

- dictionarySearch: now check for initial '/' directly instead of
  relying on fileName isAbsolute(), which now does more things

BREAKING: remove fileName::clean() const method

- relying on const/non-const to control the behaviour (inplace change
  or return a copy) is too fragile and the const version was
  almost never used.

  Replace:
      fileName sanitized = constPath.clean();

  With:
      fileName sanitized(constPath);
      sanitized.clean());

STYLE: test empty() instead of comparing with fileName::null
2021-04-19 16:33:42 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
59da4cf56d STYLE: use uintptr_t cast instead of long when reporting addresses 2019-04-29 08:15:48 +02:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
a5cc0ffcad STYLE: use const reference for caught exceptions 2019-01-23 09:03:06 +01:00
Mark Olesen
2617c326d8 ENH: extend fileName::relative() method
- optionally replace stripped parent directory with the \<case\> shortcut

    "/this/path/and/subdirs/name"

    relative("/this/path")        -> "and/subdirs/name"
    relative("/this/path", true)  -> "\<case\>/and/subdirs/name"
2018-12-14 17:44:07 +01:00
Mark Olesen
0a0fee88a0 STYLE: update fileName docs and minor code cleanup 2018-10-16 23:03:38 +02:00
Mark Olesen
6c91048e8b ENH: fileName hasPath(), removePath() methods
- improved move constructors/assignments for fileName, string, etc
2018-10-03 14:05:45 +02:00
Mark Olesen
12c903bba8 ENH: define nameOp<>, typeOp<>, sizeOp<> functors (issue #1013) 2018-09-19 15:32:04 +02:00
Mark Olesen
db1c1e89be ENH: avoid xfer on simple data types
- in many places can use move construcors or rely on RVO
2018-01-26 12:50:06 +01:00
Mark Olesen
9bd7ea593e ENH: added fileName::relative() method
- this currently just strips off the leading parent directory name

     "/this/path/and/subdirs/name"

     relative("/this/path")  -> "and/subdirs/name"
     relative("/this")       -> "path/and/subdirs/name"
2018-01-23 18:25:55 +01:00
Mark Olesen
345a2a42f1 ENH: simplify method names for reading argList options and arguments
- use succincter method names that more closely resemble dictionary
  and HashTable method names. This improves method name consistency
  between classes and also requires less typing effort:

    args.found(optName)        vs.  args.optionFound(optName)
    args.readIfPresent(..)     vs.  args.optionReadIfPresent(..)
    ...
    args.opt<scalar>(optName)  vs.  args.optionRead<scalar>(optName)
    args.read<scalar>(index)   vs.  args.argRead<scalar>(index)

- the older method names forms have been retained for code compatibility,
  but are now deprecated
2018-01-08 15:35:18 +01:00
Mark Olesen
16e75d8475 ENH: add fileName::validate static method (issue #628)
- similar to word::validate to allow stripping of invalid characters
  without triggering a FatalError.

- use this validated fileName in Foam::readDir to avoid problems when
  a directory contains files with invalid characters in their names

- adjust rmDir to handle filenames with invalid characters

- fileName::equals() static method to compare strings while ignoring
  any differences that are solely due to duplicate slashes
2017-10-26 21:23:24 +02:00
Mark Olesen
a8d2ebf298 ENH: cleanup wordRe interfaces etc.
- ensure that the string-related classes have consistently similar
  matching methods. Use operator()(const std::string) as an entry
  point for the match() method, which makes it easier to use for
  filters and predicates. In some cases this will also permit using
  a HashSet as a match predicate.

regExp
====
- the set method now returns a bool to signal that the requested
  pattern was compiled.

wordRe
====
- have separate constructors with the compilation option (was previously
  a default parameter). This leaves the single parameter constructor
  explicit, but the two parameter version is now non-explicit, which
  makes it easier to use when building lists.

- renamed compile-option from REGEX (to REGEXP) for consistency with
  with the <regex.h>, <regex> header names etc.

wordRes
====
- renamed from wordReListMatcher -> wordRes. For reduced typing and
  since it behaves as an entity only slightly related to its underlying
  list nature.

- Provide old name as typedef and include for code transition.

- pass through some list methods into wordRes

hashedWordList
====
- hashedWordList[const word& name] now returns a -1 if the name is is
  not found in the list of indices. That has been a pending change
  ever since hashedWordList was generalized out of speciesTable
  (Oct-2010).

- add operator()(const word& name) for easy use as a predicate

STYLE: adjust parameter names in stringListOps

- reflect if the parameter is being used as a primary matcher, or the
  matcher will be derived from the parameter.
  For example,
      (const char* re), which first creates a regExp
      versus (const regExp& matcher) which is used directly.
2017-05-16 23:54:43 +02:00
Mark Olesen
e379720053 ENH: additional fileName methods
- add an extension to the file name
   - remove a file extension
   - check if a file name has an extension
   - check if a file name has a particular extension (as word),
     or matches a particular grouping of extensions (as wordRe).
2016-12-18 20:40:03 +01:00
Mark Olesen
b08dadff62 ENH: initializer list constructor for fileName
This slightly more convenient when working with char[] input:

     fileName file1{ "path", "name", "to", "file.ext" };
vs.  fileName file1 = fileName(path)/"name"/"to"/"file.ext";

But is a bit more efficient since it avoid most of the intermediate
copying and resizing incurred by the '/' operator.
2016-12-18 20:09:58 +01:00
Andrew Heather
9fbd612672 GIT: Initial state after latest Foundation merge 2016-09-20 14:49:08 +01:00
Henry Weller
2bb52eff6e Test-fileName: Added recent etcFiles.H 2016-08-05 17:25:56 +01:00
mattijs
2e99db9c22 ENH: OSspecific - softlink handling (fixes #164)
Links are followed in most cases, with some notable exceptions:

- mv, mvBak:
  renames the link, not the underlying file/directory

- rmDir:
  remove the symlink to a directory, does not recurse into the
  underlying directory
2014-04-23 15:00:00 +02:00
Henry
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
Mark Olesen
97da787c69 ENH: add fileName::name(bool) for returning basename without extension 2011-03-03 13:48:04 +01:00
andy
eaef8d482b STYLE: Updated 1991 start copyright year to 2004 2011-01-14 16:08:00 +00:00
andy
099cc39e2e Revert "STYLE: 2011 copyright date."
This reverts commit b18f6cc1ce.
2011-01-05 18:24:29 +00:00
graham
b18f6cc1ce STYLE: 2011 copyright date. 2011-01-05 11:14:26 +00:00
Mark Olesen
499d48cfdb STYLE: uniform 'Test-' prefix for all applications/test
- easier to clean, avoid confusion with 'real' applications, etc.
2010-11-23 16:26:04 +01:00