Files
CoolProp/include/CPfilepaths.h
Ian Bell bc8c1bc039 C++17 modernization: remove shims, stdlib idioms, attributes, filesystem (#2688)
* chore: C++17 modernization — remove shims, use stdlib idioms

Phase 1 — Mechanical:
- Replace crossplatform_shared_ptr.h with <memory> in all 20 files; delete shim
- Replace NULL with nullptr (~10 occurrences)
- Replace throw() with noexcept (DataStructures.h)
- Convert 30+ iterator for-loops to range-for with auto/structured bindings
- Replace insert(make_pair/pair<>) with emplace/try_emplace (~40 sites)
- Replace shared_ptr<T>(new T) with make_shared<T> (~5 sites)

Phase 2 — Optional/structured bindings:
- get_alternate() returns std::optional<pair<size_t,size_t>>; remove has_valid_neighbor()
- get_set_of_tables() eliminates bool out-param, returns std::pair
- is_inside() switch refactored to IIFE eliminating nullptr-init pattern

Phase 3 — Attributes:
- Remove DEPRECATED macro; use [[deprecated("...")]] directly (PolyMath.h)
- Add [[nodiscard]] to is_inside, valid, calc_saturated_*_keyed_output,
  get_parameter_information/index, generate_update_pair, has_number

Phase 4 — Architectural:
- CPfilepaths.cpp: use std::filesystem on non-Android/Emscripten/powerpc targets
- DataStructures.h: annotate 5 public enums with explicit underlying type (: int)
- get_parameter_information() takes std::string_view for info param

Build: clean, zero errors. Test suite: 100/110 pass (10 known pre-existing failures).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove Unicode replacement character (U+FFFD) from 870.cpp

Addresses PR review comment about non-printing character on line 25.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Remove unnecessary <memory> include from IdealCurves.h

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Always use std::filesystem

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 13:28:11 -04:00

34 lines
1.1 KiB
C++

#ifndef COOLPROP_FILE_PATH_H
#define COOLPROP_FILE_PATH_H
#include <string>
#include <vector>
/// Get directory separator
std::string get_separator(void);
/// Get the user's home directory; It is believed that is is always a place that files can be written
std::string get_home_dir(void);
/// Return true if path exists
bool path_exists(const std::string& path);
/// Return merged path, append separator if string two is empty
std::string join_path(const std::string& one, const std::string& two);
/// Make directory and all required intermediate directories
void make_dirs(std::string file_path);
/// Get the size of a directory in bytes.
/// Uses std::filesystem on modern platforms (Windows, Linux, macOS).
/// Legacy Android/powerpc stub returns 0.
unsigned long long CalculateDirSize(const std::string& path);
// Get all the contents of a file and dump into a STL string
// Thanks to http://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring
std::string get_file_contents(const char* filename);
/// Get all the contents of a binary file
std::vector<char> get_binary_file_contents(const char* filename);
#endif