AnsweredAssumed Answered

Custom IDataLayer with relative paths

Question asked by metavr on Oct 14, 2014

I'm adding relative path support for a custom layer that implements IDataLayer. From what I can tell from the minimal documentation on the subject, this is handled like this:

  1. Serialize the path that gets passed to IDataLayer::put_RelativePath() during serialization (which is typically the directory containing the .mxd-- it's different when saving to .lyr though...).
  2. When deserializing the layer, find the current path of the map document containing this layer, and replace the serialized document path with the new one.

 

Here's the question: is there any other way to know the location of the map document at the time IPersist::Load() is called other than getting the AppRef? My extension is used in geoprocessing scenarios when there is no AppRef or IMxDocument. Is there any other way, or do I have to manage the map document name myself?

 

I looked at the FileStream coclass as well. I was thinking the IStream* passed to Load() might have a file reference accessor. It doesn't look like the path is exposed there either. The tagSTATSTG struct returned form IStream::Stat() looked promising, but the pwcsName member was just "Maps". So, no luck there.

 

The next question would be what if the IDataLayer is in a .lyr file rather than an .mxd? How do I find the path of the .lyr if it is moved?

Outcomes