LookupFile.hxx 1.77 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2020 The Music Player Daemon Project
3
 * http://www.musicpd.org
4 5 6 7 8 9 10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 19
 */

20 21
#ifndef MPD_LOOKUP_FILE_HXX
#define MPD_LOOKUP_FILE_HXX
22

23
#include "AllocatedPath.hxx"
24 25

struct ArchiveLookupResult {
26 27
	AllocatedPath archive = nullptr;
	AllocatedPath inside = nullptr;
28

29
	operator bool() const noexcept {
30 31 32 33
		return !archive.IsNull();
	}
};

34 35 36 37
/**
 *
 * archive_lookup is used to determine if part of pathname refers to an regular
 * file (archive). If so then its also used to split pathname into archive file
38
 * and path used to locate file in archive.
39 40 41
 * How it works:
 * We do stat of the parent of input pathname as long as we find an regular file
 * Normally this should never happen. When routine returns true pathname modified
42
 * and split into archive and inpath. Otherwise nothing happens
43
 *
44 45 46 47 48
 * For example:
 *
 * /music/path/Talco.zip/Talco - Combat Circus/12 - A la pachenka.mp3
 * is split into archive:	/music/path/Talco.zip
 * inarchive pathname:		Talco - Combat Circus/12 - A la pachenka.mp3
49 50
 *
 * Throws on error.
51
 */
52
ArchiveLookupResult
53
LookupFile(Path pathname);
54 55 56

#endif