~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to lldb/source/Host/common/File.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
318
318
    return error;
319
319
}
320
320
 
321
 
Error
322
 
File::SeekFromStart (off_t& offset)
323
 
{
324
 
    Error error;
325
 
    if (DescriptorIsValid())
326
 
    {
327
 
        offset = ::lseek (m_descriptor, offset, SEEK_SET);
328
 
 
329
 
        if (offset == -1)
330
 
            error.SetErrorToErrno();
331
 
    }
332
 
    else 
333
 
    {
334
 
        error.SetErrorString("invalid file handle");
335
 
    }
336
 
    return error;
337
 
}
338
 
 
339
 
Error
340
 
File::SeekFromCurrent (off_t& offset)
341
 
{
342
 
    Error error;
343
 
    if (DescriptorIsValid())
344
 
    {
345
 
        offset = ::lseek (m_descriptor, offset, SEEK_CUR);
346
 
        
347
 
        if (offset == -1)
348
 
            error.SetErrorToErrno();
349
 
    }
350
 
    else 
351
 
    {
352
 
        error.SetErrorString("invalid file handle");
353
 
    }
354
 
    return error;
355
 
}
356
 
 
357
 
Error
358
 
File::SeekFromEnd (off_t& offset)
359
 
{
360
 
    Error error;
361
 
    if (DescriptorIsValid())
362
 
    {
363
 
        offset = ::lseek (m_descriptor, offset, SEEK_END);
364
 
        
365
 
        if (offset == -1)
366
 
            error.SetErrorToErrno();
367
 
    }
368
 
    else 
369
 
    {
370
 
        error.SetErrorString("invalid file handle");
371
 
    }
372
 
    return error;
 
321
off_t
 
322
File::SeekFromStart (off_t offset, Error *error_ptr)
 
323
{
 
324
    off_t result = 0;
 
325
    if (DescriptorIsValid())
 
326
    {
 
327
        result = ::lseek (m_descriptor, offset, SEEK_SET);
 
328
 
 
329
        if (error_ptr)
 
330
        {
 
331
            if (result == -1)
 
332
                error_ptr->SetErrorToErrno();
 
333
            else
 
334
                error_ptr->Clear();
 
335
        }
 
336
    }
 
337
    else if (StreamIsValid ())
 
338
    {
 
339
        result = ::fseek(m_stream, offset, SEEK_SET);
 
340
        
 
341
        if (error_ptr)
 
342
        {
 
343
            if (result == -1)
 
344
                error_ptr->SetErrorToErrno();
 
345
            else
 
346
                error_ptr->Clear();
 
347
        }
 
348
    }
 
349
    else if (error_ptr)
 
350
    {
 
351
        error_ptr->SetErrorString("invalid file handle");
 
352
    }
 
353
    return result;
 
354
}
 
355
 
 
356
off_t
 
357
File::SeekFromCurrent (off_t offset,  Error *error_ptr)
 
358
{
 
359
    off_t result = -1;
 
360
    if (DescriptorIsValid())
 
361
    {
 
362
        result = ::lseek (m_descriptor, offset, SEEK_CUR);
 
363
        
 
364
        if (error_ptr)
 
365
        {
 
366
            if (result == -1)
 
367
                error_ptr->SetErrorToErrno();
 
368
            else
 
369
                error_ptr->Clear();
 
370
        }
 
371
    }
 
372
    else if (StreamIsValid ())
 
373
    {
 
374
        result = ::fseek(m_stream, offset, SEEK_CUR);
 
375
        
 
376
        if (error_ptr)
 
377
        {
 
378
            if (result == -1)
 
379
                error_ptr->SetErrorToErrno();
 
380
            else
 
381
                error_ptr->Clear();
 
382
        }
 
383
    }
 
384
    else if (error_ptr)
 
385
    {
 
386
        error_ptr->SetErrorString("invalid file handle");
 
387
    }
 
388
    return result;
 
389
}
 
390
 
 
391
off_t
 
392
File::SeekFromEnd (off_t offset, Error *error_ptr)
 
393
{
 
394
    off_t result = -1;
 
395
    if (DescriptorIsValid())
 
396
    {
 
397
        result = ::lseek (m_descriptor, offset, SEEK_END);
 
398
        
 
399
        if (error_ptr)
 
400
        {
 
401
            if (result == -1)
 
402
                error_ptr->SetErrorToErrno();
 
403
            else
 
404
                error_ptr->Clear();
 
405
        }
 
406
    }
 
407
    else if (StreamIsValid ())
 
408
    {
 
409
        result = ::fseek(m_stream, offset, SEEK_END);
 
410
        
 
411
        if (error_ptr)
 
412
        {
 
413
            if (result == -1)
 
414
                error_ptr->SetErrorToErrno();
 
415
            else
 
416
                error_ptr->Clear();
 
417
        }
 
418
    }
 
419
    else if (error_ptr)
 
420
    {
 
421
        error_ptr->SetErrorString("invalid file handle");
 
422
    }
 
423
    return result;
373
424
}
374
425
 
375
426
Error