Commit Graph

20 Commits

Author SHA1 Message Date
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