convert Unix path to DOS path

Change all forward slashes into backslashes

Download todospath.zip

Synopsis:

todospath.cpp


todospath.cpp

Synopsis
#include <string>
#include <algorithm>
using namespace std;
#include "utx.h"

string toDosPath(const string& path)
  {
  struct LocalFunc
    {
    static bool isForwardSlash(char c) { return c == '/'; }
    } ;
  string s = path;
  replace_if(s.begin(), s.end(), LocalFunc::isForwardSlash, '\\');
  return s;
  }

TEST(tdp_identities)
  {
  utxassert(toDosPath(""), "");
  utxassert(toDosPath("x"), "x");
  utxassert(toDosPath("c:\\x"), "c:\\x");
  }

TEST(tdp_1)
  {
  utxassert(toDosPath("x/y"), "x\\y");
  utxassert(toDosPath("/y"), "\\y");
  utxassert(toDosPath("x/"), "x\\");
  utxassert(toDosPath("c:x/"), "c:x\\");
  utxassert(toDosPath("/"), "\\");
  }







Contact me about content on this page using john_web-at-arrizza-dot-com
For Web Master or site problems contact: webadmin-at-arrizza-dot-com
Copyright John Arrizza (c) 2001,2002,2003,2004,2005,2006,2007