Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding documentation

  • Loading branch information...
commit d83df9535912e6b39c399844dba3b39b27c1c490 1 parent 95c0b9b
@chdemko authored
View
246 docs/manual/en-US/chapters/packages/filesystem.xml
@@ -212,6 +212,252 @@ $directory = $file->directory;
</variablelist>
</para>
</section>
+ <section>
+ <title>Calling methods</title>
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><methodname>open</methodname> method</term>
+ <listitem>
+ <para>
+ Open the file for reading or writing.
+ <programlisting language="PHP (HTML)">
+// Open the file for reading
+$file->open('r');
+
+// Open the file for writing
+$file->open('w');
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>close</methodname> method</term>
+ <listitem>
+ <para>
+ Close the file.
+ <programlisting language="PHP (HTML)">
+// Open the file for reading
+$file->open('r');
+
+// Read the file ...
+
+// Close the file
+$file->close();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>readXXX</methodname> method</term>
+ <listitem>
+ <para>
+ Read from the file. The <methodname>XXX</methodname> suffix denotes the accessor used (See Accessors).
+ <programlisting language="PHP (HTML)">
+// Open the file for reading
+$file->open('r');
+
+// Read from the file
+$line1 = $file->readLine();
+$line2 = $file->readLine();
+
+// Close the file
+$file->close();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>writeXXX</methodname> method</term>
+ <listitem>
+ <para>
+ Write to the file. The <methodname>XXX</methodname> suffix denotes the accessor used (See Accessors).
+ <programlisting language="PHP (HTML)">
+// Open the file for writing
+$file->open('w');
+
+// Write to the file
+$file->writeLine('Line 1');
+$file->writeLine('Line 2');
+
+// Close the file
+$file->close();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>flush</methodname> method</term>
+ <listitem>
+ <para>
+ Flush the file.
+ <programlisting language="PHP (HTML)">
+// Open the file for writing
+$file->open('w');
+
+// Write to the file
+$file->writeLine('Line 1');
+$file->writeLine('Line 2');
+
+// Flush the file
+$file->flush();
+
+// Close the file
+$file->close();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>truncate</methodname> method</term>
+ <listitem>
+ <para>
+ Truncate the file.
+ <programlisting language="PHP (HTML)">
+// Open the file for writing
+$file->open('w');
+
+// Write to the file
+$file->writeLine('Line 1');
+$file->writeLine('Line 2');
+
+// Truncate the file
+$file->truncate(10);
+
+// Close the file
+$file->close();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>create</methodname> method</term>
+ <listitem>
+ <para>
+ Create the file.
+ <programlisting language="PHP (HTML)">
+// Create the file on disk
+$file->create();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>delete</methodname> method</term>
+ <listitem>
+ <para>
+ Delete the file.
+ <programlisting language="PHP (HTML)">
+// Delete the file on disk
+$file->delete();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>copy</methodname> method</term>
+ <listitem>
+ <para>
+ Copy the file.
+ <programlisting language="PHP (HTML)">
+// Copy the file on another file
+$file->copy($file2);
+
+// Copy the file on a directory
+$file->copy($directory);
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>copyFromFile</methodname> method</term>
+ <listitem>
+ <para>
+ Copy from a file.
+ <programlisting language="PHP (HTML)">
+// Copy the file from another file
+$file->copyFromFile($src);
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>pullXXX</methodname> method</term>
+ <listitem>
+ <para>
+ Pull the entire contents from a file. The <methodname>XXX</methodname> suffix denotes the accessor used (See Accessors).
+ <programlisting language="PHP (HTML)">
+// Get the ini strings
+$ini = $file->pullIni();
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>pullXXX</methodname> method</term>
+ <listitem>
+ <para>
+ Push data to a file. The <methodname>XXX</methodname> suffix denotes the accessor used (See Accessors).
+ <programlisting language="PHP (HTML)">
+// Write an xml object to file
+$file->pushXml($xml);
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>iterateXXX</methodname> method</term>
+ <listitem>
+ <para>
+ Iterate from a file. The <methodname>XXX</methodname> suffix denotes the accessor used (See Accessors).
+ <programlisting language="PHP (HTML)">
+// Read lines from a file
+foreach ($file->iterateLine() as $line)
+{
+ // Deal with $line
+}
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>prependFilter</methodname> method</term>
+ <listitem>
+ <para>
+ Prepend a filter to a file.
+ <programlisting language="PHP (HTML)">
+$file->open('r')->prependFilter('string.toupper');
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>appendFilter</methodname> method</term>
+ <listitem>
+ <para>
+ Append a filter to a file.
+ <programlisting language="PHP (HTML)">
+$file->open('r')->appendFilter('string.toupper');
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><methodname>removeFilter</methodname> method</term>
+ <listitem>
+ <para>
+ Remote a filter from a file.
+ <programlisting language="PHP (HTML)">
+$file->open('r')->appendFilter('string.toupper');
+$filter = $file->appendFilter('string.tolower');
+$file->removeFilter($filter);
+</programlisting>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </section>
</section>
<section>
<title>Working with directories</title>
View
10 libraries/joomla/filesystem/element.php
@@ -338,7 +338,7 @@ public static function getInstance($path, JFilesystem $system = null)
*
* @since 12.1
*/
- public function getName()
+ protected function getName()
{
return basename($this->_path);
}
@@ -352,7 +352,7 @@ public function getName()
*
* @since 12.1
*/
- public function getBasename()
+ protected function getBasename()
{
$extension = $this->extension;
if (empty($extension))
@@ -374,7 +374,7 @@ public function getBasename()
*
* @since 12.1
*/
- public function getDirpath()
+ protected function getDirpath()
{
return dirname($this->_path);
}
@@ -388,7 +388,7 @@ public function getDirpath()
*
* @since 12.1
*/
- public function getExtension()
+ protected function getExtension()
{
return pathinfo($this->_path, PATHINFO_EXTENSION);
}
@@ -402,7 +402,7 @@ public function getExtension()
*
* @since 12.1
*/
- public function getRealpath()
+ protected function getRealpath()
{
return realpath($this->_fullpath);
}
View
16 libraries/joomla/filesystem/element/file.php
@@ -27,18 +27,21 @@
*
* @method JFilesystemElementFile open(string $mode) open the file
* @method JFilesystemElementFile close() close the file
+ * @method mixed readXXX(...) read content using accessor
+ * @method int|FALSE writeXXX(...) write content using accessor
+ * @method bool flush() flush the file
+ * @method bool truncate(int $size) truncate the file
+ *
* @method bool create() create the file
+ * @method bool delete() delete the file
+ *
* @method int|FALSE copy(JFilesystemElement $dest) copy the file
* @method int|FALSE copyFromFile(JFilesystemElementFile $src) copy from a file
- * @method bool delete() delete the file
- * @method bool flush() flush the file
- * @method bool truncate(int $size) truncate the file
- * @method int|FALSE setPosition(int $offset, int $whence) set the position
- * @method mixed readXXX(...) read content using accessor
- * @method int|FALSE writeXXX(...) write content using accessor
+ *
* @method mixed pullXXX(...) pull content using accessor
* @method int|FALSE pushXXX(...) push content using accessor
* @method JFilesystemElementFileIterator iterateXXX(...) iterate content using accessor
+ *
* @method resource prependFilter(string, int, mixed) prepend a filter
* @method resource appendFilter(string, int, mixed) prepend a filter
* @method bool removeFilter(resource) remove a filter
@@ -196,7 +199,6 @@ public function __call($method, $args)
case 'close':
case 'flush':
case 'truncate':
- case 'setPosition':
case 'copy':
case 'copyFromFile':
case 'delete':

0 comments on commit d83df95

Please sign in to comment.
Something went wrong with that request. Please try again.