~e0\dZddlZddlZddlmZdZdZdZdZd dZ d d Z e Z eZ d d Z y) zFile-system utilsN)longc:t||jdy)zCreate a file with the given content. The content is encoded with utf-8 before writing. @param path: The path to the file. @param content: The content to be written in the file. utf-8N)create_binary_fileencodepathcontents 2/usr/lib/python3/dist-packages/landscape/lib/fs.pycreate_text_filer stW^^G45cht|d5}|j|dddy#1swYyxYw)zCreate a file with the given binary content. @param path: The path to the file. @param content: The content to be written in the file. wbNopenwriter r fds r rrs1 dD R (1c:t||jdy)aAppend a file with the given content. The file is created, if it doesn't exist already. The content is utf-8 encoded before it is written. @param path: The path to the file. @param content: The content to be written in the file at the end. rN)append_binary_filerrs r append_text_filerstW^^G45r cht|d5}|j|dddy#1swYyxYw)zAppend a file with the given binary content. The file is created, if it doesn't exist already. @param path: The path to the file. @param content: The content to be written in the file at the end. abNrrs r rr*s1 dD R rcrt||dn|dz}|jdd}||S|dk\r|d|S||dS)aReturn the content of the given file as string. @param path: The path to the file. @param limit: An optional read limit. If positive, read up to that number of characters from the beginning of the file. If negative, read up to that number of bytes from the end of the file. @return content: The content of the file string, possibly trimmed to C{limit} characters. Nrreplacer)read_binary_filedecode)r limitr s r read_text_filer!6sS"tU]T JGnnWi0G } !vuvr c>t|d5}|jtjj|t |kDr?|dk\r|j |cdddS|j |tj|j cdddS#1swYyxYw)aReturn the content of the given file as bytes. @param path: The path to the file. @param limit: An optional read limit. If positive, read up to that number of bytes from the beginning of the file. If negative, read up to that number of bytes from the end of the file. @return content: The content of the file as bytes, possibly trimmed to C{limit}. rbNr)rosr getsizeabsreadseekSEEK_END)r r rs r rrQs| dD R  !6U!Czwwu~ r{{+wwy sAB/BBct|dj|%ttj|z}||f}nd}t j ||y)zTouch a file, creating it if it doesn't exist. @param path: the path to the file to be touched. @param offset_seconds: a signed integer number of seconds to offset the atime and mtime of the file from the current time. rN)rclosertimer$utime)r offset_seconds offset_time touch_times r touch_filer1isO t!499;'.8 !;/  HHT:r )N)__doc__r$r,twisted.python.compatrr rrrr!r read_file create_filer1r r r7s@ &6 6 6(   r