Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding unique path name for a given input
    primarykey
    data
    text
    <p>I'm working on a problem where I need to have a way to convert a user inputted filename to a unique path name. Let's say I let the user specify a path name that points to a file that contains some data. I can then do <code>Data* pData=Open(PathName)</code>. Now if the user specifies the same path name again, I'd like to be able to have a table of already opened files and just return a pointer to the same data: <code>Data* pData2=GetOpenedData(PathName)</code>. This is easy to accomplish with a simple <code>std::map&lt;std::string,Data*&gt;</code>, the problem is that different values of <code>PathName</code> can point to the same file. The simplest case is on Windows case insensitivity comes into play. </p> <p>The code is cross platform C++ and I don't have access to .NET stuff (but I'm happy to <code>#ifdef</code> the differences between Windows and UNIX if needed). Does anyone know of either Windows API or POSIX functions that can take a path name and return a unique (to the system) string that I can key off of. The key doesn't have to be the same in both systems (Windows/POSIX), just unique within a running instance of my code.</p> <p>For now, I'm not worried about links or two ways to get to the same file. Such as in Windows, if I had \myserver\share mapped to S: then \myserver\share\blah and S:\blah are the same file, but I can live with those being thought of as different. But S:\blah and S:\Blah should be the same. If there is a way to make \myserver\share and S:\ also be unique, that's a bonus and I'd be really happy, but I can live without it. (Likewise, if there are multiple links to the same file in UNIX).</p> <p>Edited to add:</p> <p>It's not as simple as just doing a case insensitive search in windows. For example: <code>c://data/mydata.dat</code> while that's an "invalid" filename, windows will accept it and it will actualy point to <code>c:\data\mydata.dat</code></p> <p>Edited to add another thing:</p> <p>I'd also like <code>c:\mydirectory\..\blah.dat</code> to be recognized at the same as <code>c:\blah.dat</code> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload