/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef AAPT_IO_FILE_H
#define AAPT_IO_FILE_H

#include <list>
#include <memory>
#include <vector>

#include "android-base/macros.h"
#include "androidfw/Source.h"
#include "io/Data.h"
#include "util/Files.h"
#include "util/Util.h"

namespace aapt {
namespace io {

// Interface for a file, which could be a real file on the file system, or a
// file inside a ZIP archive.
class IFile {
 public:
  virtual ~IFile() = default;

  // Open the file and return it as a block of contiguous memory. How this
  // occurs is implementation dependent. For example, if this is a file on the file
  // system, it may simply mmap the contents. If this file represents a compressed file in a
  // ZIP archive, it may need to inflate it to memory, incurring a copy.
  // Returns nullptr on failure.
  virtual std::unique_ptr<IData> OpenAsData() = 0;

  virtual std::unique_ptr<android::InputStream> OpenInputStream() = 0;

  // Returns the source of this file. This is for presentation to the user and
  // may not be a valid file system path (for example, it may contain a '@' sign to separate
  // the files within a ZIP archive from the path to the containing ZIP archive.
  virtual const android::Source& GetSource() const = 0;

  IFile* CreateFileSegment(size_t offset, size_t len);

  // Returns whether the file was compressed before it was stored in memory.
  virtual bool WasCompressed() {
    return false;
  }

  // Fills in buf with the last modification time of the file. Returns true if successful,
  // otherwise false (i.e., the operation is not supported or the file system is unable to provide
  // a last modification time).
  virtual bool GetModificationTime(struct tm* buf) const = 0;

 private:
  // Any segments created from this IFile need to be owned by this IFile, so
  // keep them
  // in a list. This will never be read, so we prefer better insertion
  // performance
  // than cache locality, hence the list.
  std::list<std::unique_ptr<IFile>> segments_;
};

// An IFile that wraps an underlying IFile but limits it to a subsection of that file.
class FileSegment : public IFile {
 public:
  explicit FileSegment(IFile* file, size_t offset, size_t len)
      : file_(file), offset_(offset), len_(len) {}

  std::unique_ptr<IData> OpenAsData() override;
  std::unique_ptr<android::InputStream> OpenInputStream() override;

  const android::Source& GetSource() const override {
    return file_->GetSource();
  }

  bool GetModificationTime(struct tm* buf) const override {
    return file_->GetModificationTime(buf);
  };

 private:
  DISALLOW_COPY_AND_ASSIGN(FileSegment);

  IFile* file_;
  size_t offset_;
  size_t len_;
};

class IFileCollectionIterator {
 public:
  virtual ~IFileCollectionIterator() = default;

  virtual bool HasNext() = 0;
  virtual IFile* Next() = 0;
};

// Interface for a collection of files, all of which share a common source. That source may
// simply be the filesystem, or a ZIP archive.
class IFileCollection {
 public:
  virtual ~IFileCollection() = default;

  virtual IFile* FindFile(android::StringPiece path) = 0;
  virtual std::unique_ptr<IFileCollectionIterator> Iterator() = 0;
  virtual char GetDirSeparator() = 0;
};

}  // namespace io
}  // namespace aapt

#endif /* AAPT_IO_FILE_H */
