PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > where is the call to tempfile in the following code?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
where is the call to tempfile in the following code?

Réponse
 
LinkBack Outils de la discussion
Vieux 16/09/2007, 01h57   #1
Cd Cd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut where is the call to tempfile in the following code?

At the following URL
http://groups.google.com/group/comp....read/thread/db...

There is the following code

#!/usr/local/ruby-1.8.0/bin/ruby
require 'ftools'
require 'tempfile'

def compete who, f
5.times do |i|
f.flock File::LOCK_EX
f.puts format("%s:%d @ %f\n",who, i, Time.now.to_f)
f.flock File::LOCK_UN
end
end

path = format(__FILE__ + '.out')
fd = open(path, File::WRONLY | File::TRUNC | File::CREAT)

if fork
compete 'PARENT', fd

Process.wait rescue nil
open(path){|f| puts f.read}
fd.close
File.rm_f path if File.exist? path

else
compete 'CHILD', fd
end

The code runs on my system. But, I don't see any call to Tempfile.new.
I'm assuming it's implied? If it is being implied, where is it being
implied at in the code?
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 16/09/2007, 12h06   #2
Marcin Raczkowski
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is the call to tempfile in the following code?

fd = open(path, File::WRONLY | File::TRUNC | File::CREAT)

  Réponse avec citation
Vieux 17/09/2007, 08h18   #3
Michael Linfield
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where is the call to tempfile in the following code?

> The code runs on my system. But, I don't see any call to Tempfile.new.
> I'm assuming it's implied? If it is being implied, where is it being
> implied at in the code?


tempfile isnt used as far as my knowledge goes...to test my theory?
delete require 'tempfile' ... if the program still runs fine then ur
gold.
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h05.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08392 seconds with 11 queries