Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Forum De Bell Tolls > Programmazione c
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Spiderweb
.fedelissimo.

User info:
Registered: Oct 2002
Posts: 51 (0.01 al dì)
Location: Vigevano
Corso: Comunicazione Digitale
Anno: 1 specialistica
Time Online: 12:50:04: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Programmazione c

Ciao ragazzi, ho un problema in c..
Siccome sto programmando un client ftp e volevo implementare il resume, mi servirebbe una funzione che legge la dimensione del file che ho appena scritto... qualcuno sa come fare?
Grazie

09-04-2003 08:01
Click Here to See the Profile for Spiderweb Click here to Send Spiderweb a Private Message Visit Spiderweb's homepage! Find more posts by Spiderweb Add Spiderweb to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lorenzo
...ma anche no.

User info:
Registered: Jun 2002
Posts: 3149 (0.37 al dì)
Location: Milano
Corso: F49
Anno: 00000011
Time Online: 49 Days, 1:47:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

code:
#include <stdio.h> #include <fcntl.h> #include <io.h> ... int handle; long filesize; handle = open("FILENAME.DAT", O_RDWR); ... filesize = filelength(handle); ... close(handle);

__________________
Non ti laureare, continua a cazzeggiare!

"È tutta merda..." - clod81

09-04-2003 12:19
Click Here to See the Profile for lorenzo Click Here to See the Blog of lorenzo Click here to Send lorenzo a Private Message Visit lorenzo's homepage! Find more posts by lorenzo Add lorenzo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nous
.:Retore Pomposo:.

User info:
Registered: Dec 2001
Posts: 2945 (0.34 al dì)
Location: Fino Mornasco - Como
Corso: Informatica
Anno: Specialista
Time Online: 16 Days, 13:56:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Lorè,a volte mi fai paura :approved:

P.s. Ma perchè apri il file in lettura e scrittura?

__________________
Cristian,il Nous che invoglia ^_^

"La capa è troppo in la,e la sbarba è troppo giovane..mi sa che qua si va in bianco"
Ryo Saeba (City Hunter)

09-04-2003 12:34
Click Here to See the Profile for nous Click Here to See the Blog of nous Click here to Send nous a Private Message Visit nous's homepage! Find more posts by nous Add nous to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lorenzo
...ma anche no.

User info:
Registered: Jun 2002
Posts: 3149 (0.37 al dì)
Location: Milano
Corso: F49
Anno: 00000011
Time Online: 49 Days, 1:47:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by nous
P.s. Ma perchè apri il file in lettura e scrittura?


Lui parla di "file che ho appena scritto", quindi immagino che ce l'abbia già aperto da prima.

__________________
Non ti laureare, continua a cazzeggiare!

"È tutta merda..." - clod81

09-04-2003 12:37
Click Here to See the Profile for lorenzo Click Here to See the Blog of lorenzo Click here to Send lorenzo a Private Message Visit lorenzo's homepage! Find more posts by lorenzo Add lorenzo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Spiderweb
.fedelissimo.

User info:
Registered: Oct 2002
Posts: 51 (0.01 al dì)
Location: Vigevano
Corso: Comunicazione Digitale
Anno: 1 specialistica
Time Online: 12:50:04: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Inserendo
int handle;
long posizione;

handle = open(retr, O_RDWR);
posizione=filelength(handle);
con gli opportuni header, dove str è una stringa contenente nome file, ottengo il seguente errore:
/home/spiderweb/tmp/ccaCZggr.o(.text+0x422): In function `resume':
: undefined reference to `filelength'
collect2: ld returned 1 exit status

come mai?

09-04-2003 18:30
Click Here to See the Profile for Spiderweb Click here to Send Spiderweb a Private Message Visit Spiderweb's homepage! Find more posts by Spiderweb Add Spiderweb to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lorenzo
...ma anche no.

User info:
Registered: Jun 2002
Posts: 3149 (0.37 al dì)
Location: Milano
Corso: F49
Anno: 00000011
Time Online: 49 Days, 1:47:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Uhm... compila ma non linka...

Vabbè, ci sono altri metodi per calcolare la dimensione del file, ma devi aprirlo come stream.


O lo apri direttamente con la fopen():

code:
FILE *stream; stream = fopen("FILENAME.DAT", "w+");


O se ce l'hai aperto da prima con la open() lo converti in stream così:
code:
FILE *stream; stream = fdopen(handle, "w+");


e poi usa questa funzione per calcolarti la dimensione:
code:
long file_length(FILE *stream) { long p, size; p = ftell(stream); fseek(stream, 0L, SEEK_END); size = ftell(stream); fseek(stream, p, SEEK_SET); return size; }



(Spero di aver scritto tutto giusto, non l'ho provato...)

__________________
Non ti laureare, continua a cazzeggiare!

"È tutta merda..." - clod81

11-04-2003 18:44
Click Here to See the Profile for lorenzo Click Here to See the Blog of lorenzo Click here to Send lorenzo a Private Message Visit lorenzo's homepage! Find more posts by lorenzo Add lorenzo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Lunik
dsy core staff

User info:
Registered: Mar 2002
Posts: 22362 (2.61 al dì)
Location: Milano
Corso: ComDig
Anno: Dott.ssa
Time Online: 93 Days, 0:52:10 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Off-Topic:
a volte Lore mi lascia :shock:

__________________
Il DSY su Facebook!!!

11-04-2003 18:45
Click Here to See the Profile for Lunik Click Here to See the Blog of Lunik Click here to Send Lunik a Private Message Visit Lunik's homepage! Find more posts by Lunik Add Lunik to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nous
.:Retore Pomposo:.

User info:
Registered: Dec 2001
Posts: 2945 (0.34 al dì)
Location: Fino Mornasco - Como
Corso: Informatica
Anno: Specialista
Time Online: 16 Days, 13:56:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Anche a me...a che serve la ftell() ??

__________________
Cristian,il Nous che invoglia ^_^

"La capa è troppo in la,e la sbarba è troppo giovane..mi sa che qua si va in bianco"
Ryo Saeba (City Hunter)

12-04-2003 00:08
Click Here to See the Profile for nous Click Here to See the Blog of nous Click here to Send nous a Private Message Visit nous's homepage! Find more posts by nous Add nous to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Spiderweb
.fedelissimo.

User info:
Registered: Oct 2002
Posts: 51 (0.01 al dì)
Location: Vigevano
Corso: Comunicazione Digitale
Anno: 1 specialistica
Time Online: 12:50:04: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Grazie mille a tutti... però adesso ho un altro problema: quando faccio la richiesta di download al server, lui riempie tutto il buffer della socket. Però il buffer della socket è limitato, nel senso che non posso mica allocare un array di 600mega: sapete come posso far dividere il file o allocare la dimensione del mio buffer dinamicamente?
Grazie

12-04-2003 09:15
Click Here to See the Profile for Spiderweb Click here to Send Spiderweb a Private Message Visit Spiderweb's homepage! Find more posts by Spiderweb Add Spiderweb to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nous
.:Retore Pomposo:.

User info:
Registered: Dec 2001
Posts: 2945 (0.34 al dì)
Location: Fino Mornasco - Como
Corso: Informatica
Anno: Specialista
Time Online: 16 Days, 13:56:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Off-Topic:
Ma perchè non usi smartFTP? :D:D:D

__________________
Cristian,il Nous che invoglia ^_^

"La capa è troppo in la,e la sbarba è troppo giovane..mi sa che qua si va in bianco"
Ryo Saeba (City Hunter)

12-04-2003 10:31
Click Here to See the Profile for nous Click Here to See the Blog of nous Click here to Send nous a Private Message Visit nous's homepage! Find more posts by nous Add nous to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CLod
JAILED

User info:
Registered: May 2002
Posts: 2688 (0.32 al dì)
Location: una delle 2 torri
Corso: Master ICT Sec
Anno: security
Time Online: 14 Days, 23:35:35 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

forse xkè deve fare un progetto per l'uni...

__________________
Se il pugno e' chiuso la mano e' vuota. Solo se la mano e' aperta puoi possedere tutto

12-04-2003 12:54
Click Here to See the Profile for CLod Click Here to See the Blog of CLod Click here to Send CLod a Private Message Find more posts by CLod Add CLod to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nous
.:Retore Pomposo:.

User info:
Registered: Dec 2001
Posts: 2945 (0.34 al dì)
Location: Fino Mornasco - Como
Corso: Informatica
Anno: Specialista
Time Online: 16 Days, 13:56:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Prova ad allocare memoria dinamicamente con la malloc passandole come parametro il sizeof del file che ti interessa.

__________________
Cristian,il Nous che invoglia ^_^

"La capa è troppo in la,e la sbarba è troppo giovane..mi sa che qua si va in bianco"
Ryo Saeba (City Hunter)

12-04-2003 13:21
Click Here to See the Profile for nous Click Here to See the Blog of nous Click here to Send nous a Private Message Visit nous's homepage! Find more posts by nous Add nous to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lorenzo
...ma anche no.

User info:
Registered: Jun 2002
Posts: 3149 (0.37 al dì)
Location: Milano
Corso: F49
Anno: 00000011
Time Online: 49 Days, 1:47:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Spiderweb
Però il buffer della socket è limitato, nel senso che non posso mica allocare un array di 600mega

code:
if ((var = (char *)malloc(629145600)) == NULL) fprintf(stderr, "Not enough memory.\n"); // :roll: :D

Beh, con una partizione di swap sufficientemente grande potresti anche farlo...



Non riesci a fare un buffer più piccolo che una volta pieno lo svuoti sul disco?

__________________
Non ti laureare, continua a cazzeggiare!

"È tutta merda..." - clod81

14-04-2003 12:50
Click Here to See the Profile for lorenzo Click Here to See the Blog of lorenzo Click here to Send lorenzo a Private Message Visit lorenzo's homepage! Find more posts by lorenzo Add lorenzo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
LazerPhEa
Vendo Steinberger GM7TA

User info:
Registered: Jul 2002
Posts: 4400 (0.52 al dì)
Location: S. Donato Beach
Corso: TICo
Anno: Finito tutto
Time Online: 83 Days, 22:35:22 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Spiderweb
Grazie mille a tutti... però adesso ho un altro problema: quando faccio la richiesta di download al server, lui riempie tutto il buffer della socket. Però il buffer della socket è limitato, nel senso che non posso mica allocare un array di 600mega: sapete come posso far dividere il file o allocare la dimensione del mio buffer dinamicamente?
Grazie

Una curiosità: hai cercato nell'RFC cosa dice riguardo alla politica di flow control lato sender?

__________________
Questo è il giardino
Dove il principe muore
Nessun sentiero
Nessun destriero
Soltanto un nome... Eterno...

14-04-2003 13:11
Click Here to See the Profile for LazerPhEa Click Here to See the Blog of LazerPhEa Click here to Send LazerPhEa a Private Message Find more posts by LazerPhEa Add LazerPhEa to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 18:56.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.060 seconds (68.88% PHP - 31.12% MySQL) con 22 query.