Fossil

Check-in [d43029f6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Handle errors in blob_read_link().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | symlinks
Files: files | file ages | folders
SHA1: d43029f6f450fbbea36199e5abdec18972c628fd
User & Date: dmitry 2011-08-28 10:43:26.142
Context
2011-08-28
11:01
Use file_delete() instead of unlink() in vfile_to_disk(). ... (check-in: 08311ffc user: dmitry tags: symlinks)
10:43
Handle errors in blob_read_link(). ... (check-in: d43029f6 user: dmitry tags: symlinks)
2011-08-27
20:37
Indicate whether a file artifact is a symlink or an executable in the web interface. ... (check-in: a7bf0e9b user: dmitry tags: symlinks)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/blob.c.
709
710
711
712
713
714
715

716
717
718
719
720


721
722
723
724
725
726
727
728
729
730
731
732
733
** Any prior content of the blob is discarded, not freed.
**
** Returns length of destination path.
**
** On windows, zeros blob and returns 0.
*/
int blob_read_link(Blob *pBlob, const char *zFilename){

#if !defined(_WIN32)
  char zBuf[1024];
  ssize_t len = readlink(zFilename, zBuf, 1023);
  blob_zero(pBlob);
  if (len > 0) {


    zBuf[len] = 0;
    blob_appendf(pBlob, "%s", zBuf);
  }
  return len;
#else
  blob_zero(pBlob);
  return 0;
#endif
}


/*
** Write the content of a blob into a file.







>



<
|
>
>
|
|
<


<







709
710
711
712
713
714
715
716
717
718
719

720
721
722
723
724

725
726

727
728
729
730
731
732
733
** Any prior content of the blob is discarded, not freed.
**
** Returns length of destination path.
**
** On windows, zeros blob and returns 0.
*/
int blob_read_link(Blob *pBlob, const char *zFilename){
  blob_zero(pBlob);
#if !defined(_WIN32)
  char zBuf[1024];
  ssize_t len = readlink(zFilename, zBuf, 1023);

  if( len < 0 ){
    fossil_panic("cannot read symbolic link %s", zFilename);
  }
  zBuf[len] = 0;   /* null-terminate */
  blob_appendf(pBlob, "%s", zBuf);

  return len;
#else

  return 0;
#endif
}


/*
** Write the content of a blob into a file.