<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog.hio.fr &#187; fichier</title>
	<atom:link href="http://blog.hio.fr/tag/fichier/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hio.fr</link>
	<description></description>
	<lastBuildDate>Tue, 07 Sep 2010 04:42:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>BASH Comment tester si un repertoire existe</title>
		<link>http://blog.hio.fr/2009/08/26/bash-comment-tester-si-un-repertoire-existe/</link>
		<comments>http://blog.hio.fr/2009/08/26/bash-comment-tester-si-un-repertoire-existe/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 08:03:30 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[fichier]]></category>
		<category><![CDATA[repertoire]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=417</guid>
		<description><![CDATA[Voila un petit bout de bash pour tester l'existence d'un repertoire ou d'un fichier]]></description>
			<content:encoded><![CDATA[<p>Voila un petit bout de bash pour tester l&#8217;existence d&#8217;un repertoire ou d&#8217;un fichier</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hio/test&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span> existe !&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>et en rajoutant un else ^^</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hio/test&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span> existe !&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span> n'existe pas!&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>et en inversant le test on rajoute juste un &laquo;&nbsp;!&nbsp;&raquo; devant le &laquo;&nbsp;-d&nbsp;&raquo;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;"><span style="color: #c20cb9; font-weight: bold;">dir</span></span>=<span style="color: #ff0000;">&quot;/home/hio/test&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span> n'existe pas!&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$dir</span> existe !&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>Voila, c&#8217;est pas tres compliquer ^^ et pour tester l&#8217;existence d&#8217;un fichier, on remplace juste le &laquo;&nbsp;-d&nbsp;&raquo; par un &laquo;&nbsp;-f&nbsp;&raquo;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/08/26/bash-comment-tester-si-un-repertoire-existe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP comment recuperer l&#8217;extension d&#8217;un fichier</title>
		<link>http://blog.hio.fr/2009/04/17/php-comment-recuperer-lextension-dun-fichier/</link>
		<comments>http://blog.hio.fr/2009/04/17/php-comment-recuperer-lextension-dun-fichier/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 13:42:25 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[fichier]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=302</guid>
		<description><![CDATA[Une fonction php pratique qui permet de récupérer l'extension d'un fichier, ce n'est pas la seul façon de faire
mais c'est la façon que je trouve être la plus propre.]]></description>
			<content:encoded><![CDATA[<p>Une fonction php pratique qui permet de récupérer l&#8217;extension d&#8217;un fichier,<br />
ce n&#8217;est pas la seul façon de faire mais c&#8217;est la façon que je trouve être la plus propre.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">return</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Utilisation</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$extension</span> <span style="color: #339933;">=</span> getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_memory_remains.mp3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$extension</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Ce qui donnera</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">mp3</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/04/17/php-comment-recuperer-lextension-dun-fichier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Lire un fichier texte</title>
		<link>http://blog.hio.fr/2009/03/18/php-lire-un-fichier-texte/</link>
		<comments>http://blog.hio.fr/2009/03/18/php-lire-un-fichier-texte/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 16:16:22 +0000</pubDate>
		<dc:creator>HiO</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[fichier]]></category>

		<guid isPermaLink="false">http://blog.hio.fr/?p=224</guid>
		<description><![CDATA[Comment lire un fichier texte en php ?]]></description>
			<content:encoded><![CDATA[<p>Comment lire un fichier texte en php ?</p>
<p>et bien comme ça ^^</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'file.txt'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$line</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$line</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://fr3.php.net/manual/fr/function.fopen.php">fopen</a>, <a href="http://fr3.php.net/manual/fr/function.fgets.php">fgets</a></p>
<p>Bon voila rien de très compliqué et ca peu en aider certain.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hio.fr/2009/03/18/php-lire-un-fichier-texte/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
