On Sat, 3 Nov 2007, Dr J A Gow wrote:
On Sat, 2007-11-03 at 13:23 +0100, Riccardo Di Meo wrote:
Hi everyone,
i have noticed that the function CESetEndOfFile has been disabled in
the the svn (src/rapi_indirection.c, twogood at 2007-09-15), though is
enabled in the current release of synce (0.10.0, if im not wrong): is
there any way i can help in order to have it back?
I am the (now and then) developer of Fur (Fuse + synce filesystem) and
i need the CESetEndOfFile call for my code: at the moment i am forced
to point users willing to use Fur to the sforge packages (which is not
bad since all distributions are likely to use them), however i don't
like it since im diverting potential beta testers from your project.
If CeSetEndOfFile is not going to come back soon, can you tell me the
reasons for silencing it? In this way i could tell people willing to
compile Fur and Synce (from svn) to re-enable it with full knowledge
of what they are risking.
I have a HTC S620 (WM6) perfectly working with Synce (i didn't
stressed it though), and i know what an EOF is :-) : if i may help you
debug the problem, I'll be at your service.
Thank you for what you have already done.
Best Regards,
Riccardo Di Meo
Mmm, yes, what gives? I thought this was a reasonable implementation.
John.
I have put together a small program to test the CeSetEndOfFile call
and now im positive that twogood had his good reasons to disable the
call...
The code is attached (it's only a test and it's been a while since i
last coded in C, and even more since i handled the librapi, therefore
be nice ;-) ).
The device is the aforementioned S620, the test consists in creating a
file, writing some data into it (1th arg is the size), seek to a
position from the start (2th arg), truncate, get the size and close.
From my tests, _on_my_specific_device_, it seems that CeSetEndOfFile
doesn't work in the 0.10.0 release and it almost work in the svn
version (after re-enabling it).
I underlined _on_my_specific_device_ since im pretty sure that the
call works fine with PocketPc2003 devices (i didn't tested with this
implementation, but i remember i wrote it on my own by analogy with
the other Rapi calls and it worked out of the box with my old hp1900).
* 0.10.0 package from sourceforge:
CeSetEndOfFile succeeds (return value != FALSE), however the file is
not truncated (both CeGetFileSize and the device confirm it)
----------
./test 1024000 512000
The size of the file is: 1024000 (truncated at 512000 from start)
----------
where i expected a file size of 512000 (BTW, how do i increase the
verbosity, if possible?)
* svn of 3 days ago, '#if 0' removed from CeSetEndOfFile.
CeSetEndOfFile returns FALSE (failed) and i get a debug message:
----------
./test 1024000 512000
[rapi_buffer_read_data:374] unable to read 4 bytes. read_index=8,
bytes_used=8
CeSetEndOfFile failed
----------
however the call _does_ work, and if ignore the check for the return
value, i get:
----------
./test 1024000 512000
[rapi_buffer_read_data:374] unable to read 4 bytes. read_index=8,
bytes_used=8
CeSetEndOfFile failed
The size of the file is: 512000 (truncated at 512000 from start)
----------
which is what i expected for a correct execution.
I have also two PDA (an old hp1915, PocketPC2003 and a hp2100 (i
think) Windows Mobile 2005) both ipaq.ko based and working with Synce:
I'll try with them too and paste the results, hoping it will be of
help, however if you need something else, just ask.
Regards,
Riccardo Di Meo
#include <stdlib.h>
#include <stdio.h>
#include <rapi.h>
#include <synce.h>
#include <unistd.h>
void __write_some_data(HANDLE handle,DWORD size)
{
DWORD buffer[size],i;
DWORD got;
BOOL result;
for(i=0;i<size;i++)
buffer[i]=i;
result=CeWriteFile((HANDLE) handle,(LPVOID) buffer,(DWORD) size,&got,NULL);
if(result==FALSE) {
fprintf(stderr,"CeWriteFile failed!\n");
exit(4);
}
}
HANDLE create_test_file(int size,char *filename)
{
LPWSTR path;
HANDLE handle;
if (size==-1) {
size=1024;
}
if(filename==NULL)
path=wstr_from_current("\\CeSetEndOfFile_Test.txt");
else
path=wstr_from_current(filename);
if(path==NULL) {
fprintf(stderr,"Path not created!\n");
exit(2);
}
CeDeleteFile(path);
handle=CeCreateFile(path,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0);
if(handle==0) {
fprintf(stderr,"CeCreateFile failed!\n");
exit(3);
}
free(path);
__write_some_data(handle,size);
return handle;
}
int main(int argc,char **argv)
{
HANDLE handle;
int filesize;
BOOL result;
LONG seek;
if(argc<3) {
fprintf(stderr,"Too few arguments.\n\tUsage:\n%s filesize seek_point\n",argv[0]);
return 1;
}
filesize=atol(argv[1]);
if(filesize<=0)
filesize=0;
else
if(filesize>1e7)
filesize=10000000;
seek=(LONG) atol(argv[2]);
// Init the Rapi support
if(CeRapiInit()) {
fprintf(stderr,"Rapi not initialized!\n");
return 1;
}
atexit((void*) CeRapiUninit);
// Create a test file
handle=create_test_file(filesize,NULL);
// "Seek"
if((LONG) CeSetFilePointer(handle,(LONG) seek,NULL,FILE_BEGIN)!=seek) {
fprintf(stderr,"CeSetFilePointer failed\n");
return 5;
}
// Truncate it
result=CeSetEndOfFile(handle);
#define IGNORE
if(result==FALSE) {
fprintf(stderr,"CeSetEndOfFile failed\n");
#ifndef IGNORE
return 6;
#endif
}
// Get the size of the file.
printf("The size of the file is: %d (truncated at %d from start)\n",CeGetFileSize(handle,NULL),(int) seek);
// Close
CeCloseHandle(handle);
return 0;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
SynCE-Devel mailing list
SynCE-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synce-devel