// Copyright 2014 The Kyua Authors.1// All rights reserved.2//3// Redistribution and use in source and binary forms, with or without4// modification, are permitted provided that the following conditions are5// met:6//7// * Redistributions of source code must retain the above copyright8// notice, this list of conditions and the following disclaimer.9// * Redistributions in binary form must reproduce the above copyright10// notice, this list of conditions and the following disclaimer in the11// documentation and/or other materials provided with the distribution.12// * Neither the name of Google Inc. nor the names of its contributors13// may be used to endorse or promote products derived from this software14// without specific prior written permission.15//16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.2728/// \file store/layout.hpp29/// File system layout definition for the Kyua data files.30///31/// Tests results files are all stored in a centralized directory by default.32/// In the general case, we do not want the user to have to worry about files:33/// we expose an identifier-based interface where each tests results file has a34/// unique identifier. However, we also want to give full freedom to the user35/// to store such files wherever he likes so we have to deal with paths as well.36///37/// When creating a new results file, the inputs to resolve the path can be:38/// - NEW: Automatic generation of a new results file, so we want to return its39/// public identifier and the path for internal consumption.40/// - A path: The user provided the specific location where he wants the file41/// stored, so we just obey that. There is no public identifier in this case42/// because there is no naming scheme imposed on the generated files.43///44/// When opening an existing results file, the inputs to resolve the path can45/// be:46/// - LATEST: Given the current directory, we derive the corresponding test47/// suite name and find the latest timestamped file in the centralized48/// location.49/// - A path: If the file exists, we just open that. If it doesn't exist or if50/// it is a directory, we try to resolve that as a test suite name and locate51/// the latest matching timestamped file.52/// - Everything else: Treated as a test suite identifier, so we try to locate53/// the latest matchin timestamped file.5455#if !defined(STORE_LAYOUT_HPP)56#define STORE_LAYOUT_HPP5758#include "store/layout_fwd.hpp"5960#include <string>6162#include "utils/datetime_fwd.hpp"63#include "utils/fs/path_fwd.hpp"6465namespace store {66namespace layout {676869extern const char* results_auto_create_name;70extern const char* results_auto_open_name;7172utils::fs::path find_results(const std::string&);73results_id_file_pair new_db(const std::string&, const utils::fs::path&);74utils::fs::path new_db_for_migration(const utils::fs::path&,75const utils::datetime::timestamp&);76utils::fs::path query_store_dir(void);77std::string test_suite_for_path(const utils::fs::path&);787980} // namespace layout81} // namespace store8283#endif // !defined(STORE_LAYOUT_HPP)848586