Commit Graph

38 Commits

Author SHA1 Message Date
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
1883a872a1 STYLE: adds comments in empty Make/options files
- easier when making modifications

STYLE: spelling in topoSetSource comments
2018-11-13 15:21:13 +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
Mark Olesen
d29c438657 STYLE: use url for FSF license instead of postal address, switch to GPL v3 2010-03-29 14:07:56 +02:00
Mark Olesen
78e41f78bd STYLE: avoid spaces around fileName::operator/ except when split across lines 2010-02-18 10:51:56 +01:00
Mark Olesen
fa93ce8cd7 coding style adherence
- markup codingStyleGuide.org examples so they actually indent correctly

- use 'Info<<' as per codingStyleGuide instead of 'Info <<'
2009-11-27 15:39:14 +01:00
Mark Olesen
fe6a83a3a8 moved fileName::IOobjectComponents -> IOobject::fileNameComponents 2009-01-30 09:06:47 +01:00
Mark Olesen
defe13e205 fileName gets additional convenience methods
- exists() = forward to OSspecific exists(...)
- isDir()  = forward to OSspecific dir(...)
- isFile() = forward to OSspecific file(...)
- IOobjectComponents() - split into instance, local, name following rules
  set out for IOobject.

- added IOobject(path, registry, ...) constructor that uses
  fileName::IOobjectComponents(). This hides the complexity we otherwise need.
2009-01-27 13:28:45 +01:00
Mark Olesen
28b200bcd9 update copyrights for 2009 2008-12-31 19:01:56 +01:00
Mark Olesen
0571f5393e rename Foam::dotFoam() -> Foam::findEtcFile() with an optional 'mandatory' argument
- if mandatory is true, findEtcFile() will abort with a message (via cerr).
  This allows a non-existent file to be caught at the lowest level and avoid
  error handling in IFstream, which might not be initialized at that stage.
2008-12-12 19:16:32 +01:00
Mark Olesen
02cabc3cf2 updated Copyright (C) \d+-2008 OpenCFD Ltd. 2008-06-25 15:01:46 +02:00
OpenFOAM-admin
3170c7c0c9 Creation of OpenFOAM-dev repository 15/04/2008 2008-04-15 18:56:58 +01:00