有dataWithContentsOfURL
,someFileHandle.readData(ofLength: bufferSize)
和FileManager
的示例,并且流读写文件。但是它们都只处理一个文件。
假设我要获取目录的内容(通过URL或路径),获取目录的原始“数据”。然后进行加密/解密或压缩/解压缩,并将其写回到磁盘保留目录结构和每一位。
我正在考虑使用contentsOfDirectory
的函子subpathsOfDirectory
或FileManager.DirectoryEnumerator
,甚至使用更重的iex(1)> h Ecto.Repo.delete
No documentation for function Ecto.Repo.delete was found, but there is a callback with the same name.
You can view callback documentations with the b/1 helper.
iex(2)> b Ecto.Repo.delete
@callback delete(
struct_or_changeset ::
Ecto.Schema.t() | Ecto.Changeset.t(),
opts :: Keyword.t()
) ::
{:ok, Ecto.Schema.t()}
| {:error, Ecto.Changeset.t()}
Deletes a struct using its primary key.
If the struct has no primary key,
Ecto.NoPrimaryKeyFieldError will be raised. If the struct
has been removed from db prior to call,
Ecto.StaleEntryError will be raised.
It returns {:ok, struct} if the struct has been
successfully deleted or {:error, changeset} if there was a
validation or a known constraint error.
## Options
• :prefix - The prefix to run the query on (such as
the schema path in Postgres or the database in MySQL).
This overrides the prefix set in the query and any
@schema_prefix set in the schema.
• :stale_error_field - The field where stale errors
will be added in the returning changeset. This option
can be used to avoid raising Ecto.StaleEntryError.
• :stale_error_message - The message to add to the
configured :stale_error_field when stale errors happen,
defaults to "is stale".
See the "Shared options" section at the module
documentation.
## Example
post = MyRepo.get!(Post, 42)
case MyRepo.delete post do
{:ok, struct} -> # Deleted with success
{:error, changeset} -> # Something went wrong
end
列出每个项目,然后获取每个人的数据并附加。或为每个文件创建一个流,然后将它们组合为一个。
看起来很普通,所以我不想在这里发明自行车。但是,找不到在Swift中进行此类操作的好例子。