Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10709

Re: Hardlink sub-directories and files

Date 2011-08-02 12:13 +0200
From Thomas Jollans <t@jollybox.de>
Subject Re: Hardlink sub-directories and files
References <3d2c3d3b-085e-4f3b-903d-726a31e607f4@b34g2000yqi.googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1756.1312280004.1164.python-list@python.org> (permalink)

Show all headers | View raw


On 02/08/11 11:32, loial wrote:
> I am trying to hardlink all files in a directory structure using
> os.link.
> 
> This works fine for files, but the directory also contains sub-
> directories (which themselves contain files and sub-directories).
> However I do not think it is possible to hard link directories ?
> 
> So presumably I would need to do a mkdir for each sub-directory
> encountered?
> Or is there an easier way to hardlink everything in a directory
> structure?.
> 
> The requirement is for hard links, not symbolic links
> 

Yes, you have to mkdir everything. However, there is an easier way:

subprocess.Popen(['cp','-Rl','target','link'])

This is assuming that you're only supporting Unices with a working cp
program, but as you're using hard links, that's quite a safe bet, I
should think.

- Thomas

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Hardlink sub-directories and files loial <jldunn2000@gmail.com> - 2011-08-02 02:32 -0700
  Re: Hardlink sub-directories and files Peter Otten <__peter__@web.de> - 2011-08-02 12:01 +0200
  Re: Hardlink sub-directories and files Thomas Jollans <t@jollybox.de> - 2011-08-02 12:13 +0200
  Re: Hardlink sub-directories and files Tim Chase <python.list@tim.thechases.com> - 2011-08-02 06:17 -0500
  Re: Hardlink sub-directories and files Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-08-02 21:46 -0700
  Re: Hardlink sub-directories and files Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2011-08-03 12:02 +0530
    Re: Hardlink sub-directories and files Grant Edwards <invalid@invalid.invalid> - 2011-08-03 14:22 +0000
      Re: Hardlink sub-directories and files Thomas Jollans <t@jollybox.de> - 2011-08-03 17:08 +0200
      Re: Hardlink sub-directories and files Ned Deily <nad@acm.org> - 2011-08-03 12:57 -0700
  Re: Hardlink sub-directories and files Nobody <nobody@nowhere.com> - 2011-08-03 08:04 +0100
  Re: Hardlink sub-directories and files Thomas Jollans <t@jollybox.de> - 2011-08-03 11:47 +0200
  Re: Hardlink sub-directories and files Thomas Jollans <t@jollybox.de> - 2011-08-03 20:49 +0200
  Re: Hardlink sub-directories and files Thomas Jollans <t@jollybox.de> - 2011-08-03 23:54 +0200
  Re: Hardlink sub-directories and files Alexander Gattin <xrgtn@yandex.ru> - 2011-08-08 10:07 +0300

csiph-web