0

I have problem in making a adobe plugin to get the path of the open document, when i just tried javascript tool to insert a tool box in Adobe, In that i managed to get the path using the script below.

  var path = this.path.split('"/');

I want know how to get the path in c++ Like this or just how to use the same code type in c++. Please help me with this Thank you.

  • You could try the Boost FileSystem Library. Other than having a current_path function, it also provides portable path parsing which would otherwise be very hard to get right. – Veritas Jul 03 '14 at 07:31

2 Answers2

1

I guess you want to tokenize path variable. If so have a look on

How do I tokenize a string in C++?

Community
  • 1
  • 1
Doonyx
  • 580
  • 3
  • 12
1

If you are using plain c++, you can use the following code:

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>

int main() {
  using namespace std;
  vector<string> v;
  string s = "/path/to/foo/bar";
  istringstream iss(s);
  while (!iss.eof())
  {
    string x;
    getline(iss, x, '/');
    v.push_back(x);
  }

  for (vector<string>::iterator it = v.begin() ; it != v.end(); ++it)
    cout << *it << endl;
}

Source: http://www.cplusplus.com/faq/sequences/strings/split/, section iostreams and getline() modified to use a vector.

Nicop
  • 314
  • 1
  • 6