author | zecke <zecke> | 2003-02-16 21:01:09 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-16 21:01:09 (UTC) |
commit | 892a453a931b41967c7dca72097da9c5be7f84d6 (patch) (unidiff) | |
tree | c687518f02064dd5d7c94f57e519243dd3ea5dfe /core/obex/receiver.cpp | |
parent | 64178d4839f12540b8a3d19cf79c9c2b1d33707e (diff) | |
download | opie-892a453a931b41967c7dca72097da9c5be7f84d6.zip opie-892a453a931b41967c7dca72097da9c5be7f84d6.tar.gz opie-892a453a931b41967c7dca72097da9c5be7f84d6.tar.bz2 |
its memcpy(destination, src
and not vice versa....
-rw-r--r-- | core/obex/receiver.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index d5a7271..31c6afe 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp | |||
@@ -128,43 +128,45 @@ void OtherHandler::accept() { | |||
128 | delete this; | 128 | delete this; |
129 | } | 129 | } |
130 | void OtherHandler::deny() { | 130 | void OtherHandler::deny() { |
131 | QFile::remove( m_file ); | 131 | QFile::remove( m_file ); |
132 | delete this; | 132 | delete this; |
133 | } | 133 | } |
134 | QString OtherHandler::targetName( const QString& file ) { | 134 | QString OtherHandler::targetName( const QString& file ) { |
135 | QFileInfo info( file ); | 135 | QFileInfo info( file ); |
136 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); | 136 | QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); |
137 | QString newFileBase = newFile; | 137 | QString newFileBase = newFile; |
138 | 138 | ||
139 | int trie = 0; | 139 | int trie = 0; |
140 | while (QFile::exists(newFile + info.extension() ) ) { | 140 | while (QFile::exists(newFile + "."+info.extension() ) ) { |
141 | newFile = newFileBase + "_"+QString::number(trie) ; | 141 | newFile = newFileBase + "_"+QString::number(trie) ; |
142 | trie++; | 142 | trie++; |
143 | } | 143 | } |
144 | newFile += info.extension(); | 144 | newFile += "." + info.extension(); |
145 | 145 | ||
146 | return newFile; | 146 | return newFile; |
147 | } | 147 | } |
148 | 148 | ||
149 | /* fast cpy */ | 149 | /* fast cpy */ |
150 | void OtherHandler::copy(const QString& src, const QString& file) { | 150 | void OtherHandler::copy(const QString& src, const QString& file) { |
151 | qWarning("src %s, dest %s", src.latin1(),file.latin1() ); | ||
151 | int src_fd = ::open( QFile::encodeName( src ), O_RDONLY ); | 152 | int src_fd = ::open( QFile::encodeName( src ), O_RDONLY ); |
152 | int to_fd = ::open( QFile::encodeName( file), O_RDWR| O_CREAT| O_TRUNC, | 153 | int to_fd = ::open( QFile::encodeName( file), O_RDWR| O_CREAT| O_TRUNC, |
153 | S_IRUSR, S_IWUSR, S_IRGRP, S_IRGRP ); | 154 | S_IRUSR, S_IWUSR, S_IRGRP, S_IRGRP ); |
154 | 155 | ||
155 | struct stat stater; | 156 | struct stat stater; |
156 | ::fstat(src_fd, &stater ); | 157 | ::fstat(src_fd, &stater ); |
157 | ::lseek(to_fd, stater.st_size-1, SEEK_SET ); | 158 | ::lseek(to_fd, stater.st_size-1, SEEK_SET ); |
159 | ::write(to_fd, "", 1 ); | ||
158 | 160 | ||
159 | void *src_addr, *dest_addr; | 161 | void *src_addr, *dest_addr; |
160 | src_addr = ::mmap(0, stater.st_size, PROT_READ, | 162 | src_addr = ::mmap(0, stater.st_size, PROT_READ, |
161 | MAP_FILE | MAP_SHARED, src_fd, 0 ); | 163 | MAP_FILE | MAP_SHARED, src_fd, 0 ); |
162 | dest_addr= ::mmap(0, stater.st_size, PROT_READ | PROT_WRITE, | 164 | dest_addr= ::mmap(0, stater.st_size, PROT_READ | PROT_WRITE, |
163 | MAP_FILE | MAP_PRIVATE, to_fd, 0 ); | 165 | MAP_FILE | MAP_PRIVATE, to_fd, 0 ); |
164 | 166 | ||
165 | ::memcpy(src_addr , dest_addr, stater.st_size ); | 167 | ::memcpy(dest_addr , src_addr, stater.st_size ); |
166 | ::munmap(src_addr , stater.st_size ); | 168 | ::munmap(src_addr , stater.st_size ); |
167 | ::munmap(dest_addr, stater.st_size ); | 169 | ::munmap(dest_addr, stater.st_size ); |
168 | 170 | ||
169 | // done | 171 | // done |
170 | } | 172 | } |