Giter VIP home page Giter VIP logo

pathwrap's Introduction

pathwrap

You can get the special path of windows in modern C++.

Requirement

  • C++17

Usage

You can get the desktop path in the following cases.

If it fails, a runtime_error is thrown.

#include <filesystem>

#include <ShlObj.h>
#include "pathwrap.hpp"


std::filesystem::path path = pathwrap::get_special_path(CSIDL_DESKTOP);

If you don't want to be thrown an exception:

#include <filesystem>
#include <optional>
#include <system_error>

#include <ShlObj.h>
#include "pathwrap.hpp"


std::error_code code;
std::filesystem::path path_code = pathwrap::get_special_path(CSIDL_DESKTOP, code);
std::filesystem::path path_code = pathwrap::error_code::get_special_path(CSIDL_DESKTOP, code);
// this uses error_code instead of throwing an exception.
// The error_code namespace is an inline namespace, so both are the same.

std::optional<std::filesystem::path> path_optional = pathwrap::optional::get_special_path(CSIDL_APPDATA);
// You can also use std::optional.

if (!path_code) {
	// Processing when acquisition of special path is successful.
}

if (path_optional.has_value()) {
	// Processing when acquisition of special path is successful.
}

Of course, you can also get many paths other than desktop.

pathwrap::get_special_path(CSIDL_MYVIDEO);
pathwrap::get_special_path(CSIDL_WINDOWS);
pathwrap::get_special_path(CSIDL_STARTUP);
pathwrap::get_special_path(CSIDL_MYDOCUMENTS);
pathwrap::get_special_path(CSIDL_FAVORITES);

For more information, search for CSIDL values.

Founder

pathwrap's People

Contributors

cpyberry avatar

Stargazers

 avatar Onur ULUSOY avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.