CRelativePaths v1.06 Convert relative
to absolute paths and vice versa
Welcome to CRelativePaths, a C++ class to convert to and from relative
paths, This is similar to how Visual Studio stores filenames in a project / workspace.
This means that you can copy a project to a different drive and recompile without
problems.
The enclosed zip file contains the source
code and a simple VC2017 test application which exercises the class.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
Updates
v1.06 (3 February 2025)
- Updated copyright details.
- Reworked code to use std::filesystem::path.
v1.05 (15 April 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.04 (17 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.03 (15 December 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Removed code path which supported RELATIVEPATHS_MFC_EXTENSIONS
define
1 May 2017
- Updated the demo app to compile cleanly using /permissive-.
27 December 2015
- Verified the code compiles cleanly on VC 2015.
v1.02 (28 June 2015)
- Updated copyright details.
- Updated the code to clean compile on VC 2008 & later
- Updated the code to require VC 2005 or later
- Updated the code to be a header only implementation
- Reworked the RelativeToAbsolute method to return the string return value
as an output parameter instead of a return value.
- Updated the code to include SAL annotations.
- Reworked the code to optionally compile without MFC. By default the code
now use STL classes and idioms but if you define RELATIVEPATHS_MFC_EXTENSIONS
the code will revert back to the MFC behaviour.
- Removed the static critical section member variable of the CRelativePaths
class. Please note that while the RelativeToAbsolute method is executing it
is possible that code in some other thread of your app could also be modifying
the current working directory. To avoid such race conditions you should serialize
that code with the execution of RelativeToAbsolute with something like a critical
section.
v1.01 (28 December 2006)
- Updated copyright details
- Addition of a CRELATIVEPATHS_EXT_CLASS preprocessor macro to allow the classes
to be more easily added to an extension dll
- Updated the code to clean compile on VC 2005
- Updated the documentation to use the same style as the web site
V1.0 (7 April 2003)