path NaiveUncomplete ( const path file, const path base ) { if ( file.has_root_path() ) { if ( file.root_path() != base.root_path() ) { return file; } else { return NaiveUncomplete ( file.relative_path(), base.relative_path() ); } } else { if ( file.has_root_path() ) { throw "cannot uncomplete a path relative path from a rooted base"; } else { typedef path::const_iterator path_iterator; path_iterator path_it = file.begin(); path_iterator base_it = base.begin(); while ( path_it != file.end() && base_it != base.end() ) { if ( *path_it != *base_it ) { break; } ++path_it; ++base_it; } path result; for ( ; base_it != base.end(); ++base_it ) { result /= ".."; } for ( ; path_it != file.end(); ++path_it ) { result /= *path_it; } return result; } } } // NaiveUncomplete