---
name: "Zim::File"
section: "3pm"
platform: "linux"
package: "zim"
version: "0.17-1"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/Zim::File"
---

# Zim::File(3pm)

Zim::File - OO wrapper for files

```
        $file = Zim::File->new('./Changes');
        $text = $changes."\n\n".$file->read;
        $file->write($text);
```

This package provides an object for handling files. It bundles some snippets of code that are needed by several modules. This class overloads the '""' operator, so the string version of an object is the file path. Simple constructor, uses File::Spec's `"catfile"` when multiple arguments are given. Returns the full path to the file. Returns the filename part of the path. Returns the directory part of the path. Returns the contents of the file. Takes list context in account. Returns empty when the file does not exist. Read and parses contents. Returns a hash with key value mappings and a list which indicates the order in which the keys were found. Searches for KEY in a plain text hash. The boolean CASE should be set for case sensitive lookup. Case insensitive is the default. Write CONTENT to file. Creates file and parent directories when needed. Append content to file. Creates file and parent directories when needed. Writes a list of keys and values to file. A second argument can be used to enforce the order of the keys in the config file; this is optional. Delete the file. Removes parent directories when empty. Returns boolean. Returns a hash reference with stat values. Returns an IO::File object. Line based grep function.\
 **Class Methods** The following methods don't need an object to work on. They can also be called as for example `"Zim::File->make_dir($dir)"`. Of course they can also be called on a Zim::File object. Turn a relative filename or a file uri into a local path name and cleans up this path to a logical form. It also does tilde  expansion.

If REFERENCE is omitted the current dir is used.

Calls `"parse_uri()"` first when needed. Method for parsing file uris, returns either a normal path or a (new) uri. No url decoding is done here. Turns a path into an uri. Does no checks. Returns platform dependend version of FILE. Copy content from one file to another. Creates parent directories if needed. Move file contents from one place to another. Takes care of creating and cleaning up parent directories. Returns a list of items for DIR. Ignores hidden files. Returns all items in DIR that match REGEX. Create DIR is it doesn't exist already. Subtle differences with File::Path. Removes a directory and it's parents when they are empty. Fails silently. Look for a file below ROOT that kind of looks like `@PARTS`. Options that can be passed in `%OPT` include: File extension to add to the last part when resolving a file.

If a dir does not exist we try a file with this extension to resolve the right case. We are looking for a dir. Jaap Karssenberg (Pardus) \<pardus@cpan.org\> Copyright (c) 2006 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Zim
